Re: Sending server commands
You are on the right track yes.
There doesn't seem to be anything wrong with that code. I would suggest you read more than 20 bytes of data upon each iteration of fgets($handle, 20), for example 128 bytes.
If your getting a blank screen, with that code it could mean there's an error in the code or the server did not send any messages back.
If your setup is to not show errors, the white screen could indicate a fatal error such as sockets not enabled. Check your error_log file for problems.
I would put an echo in the 'else' and make sure that it's getting to that part (at the start and end). If those show then there is no fatal error.
If you are happy there's no problems with the script then verify the server is working as it should. Check that the port is open, check the port number. Is the server behind a router/firewall?