in reply to More sockets (sob!)

After more rummaging, I discovered the answer in perlfunc:sysread. The section is:

It bypasses stdio, so mixing this with other kinds of reads, `print', `write', `seek', `tell', or `eof' can cause confusion because stdio usually buffers data.... There is no syseof() function, which is ok, since eof() doesn't work very well on device files (like ttys) anyway. Use sysread() and check for a return value for 0 to decide whether you're done.

So I simply removed the "if(not eof($socket))" section, and moved the "Another closed socket" else case into the if($read_count < 4) section. Voila!

Perldoc. It's your friend.