in reply to is the socket done or not?

Don't use IO::Select with buffered reads or writes. Dunno if that'll solve it entirely, but that's at least a partial problem.

-- Randal L. Schwartz, Perl hacker