in reply to Why won't this read?
Or you can try the orig. code with $remote_port=7; which is the echo port. I know it tests reading and writing, but then you know the code is right if it works.
Be sure you or some sysadmin has not turned off echo/tcp. To test this do a telnet to port 7 and see if your input is echoed. You can also use a telnet to your server to see if it echoes.