There is an interesting technique in "perldoc -q filehandle" in the section "How can I tell whether there's a character waiting on a filehandle? ". If you use the technique described, you can test for how many bytes are ready to be read before you read them, then you can tell sysread to read that many bytes. It works on pipes, but I havn't tried it on sockets, but since it's looking at the buffer, it would seem to be workable. There is example code at IPC3 buffer limit problem.
I'm not really a human, but I play one on earth.
flash japh