This sounds like a buffering problem - close the socket on
the client when you've finished sending data, or use
sysread() and syswrite() (and no other IO calls) to
access the socket data. I wrote a longer article on this
at Socket.pm nonblocking.
in reply to When do I stop reading?
Update: This happens because all of perl's standard
file operators - including things like eof() - are buffered,
and read ahead when called. This usually isn't a problem,
but with a filehandle that may block (eg a socket or a pipe), perl may block while reading ahead, so you don't see the data until it finishes. Sometimes you write some data to a socket and close it straight away - you won't see the problem here, as perl will stop reading when it gets the EOF. However, if you are trying to do something interactively, where the client socket stays open, you may find perl blocks before you get all the data that is available. sysread() and syswrite() bypass all this, so you can read right up to the last byte using them :-) Remember to check the return values for errors and EOF.