As
cdarke suggests, I would also recommend looking into the four argument version of
select in which case it's not necessary to make
recv non-blocking. However, I am now telling people to use
select via the module
IO::Select when applicable because it makes it so much easier to use. In fact, I think the core perl documentation should be updated to at least mention the existence of
IO::Select if not also to show examples from it. It would make the concept much more accessible and attractive, and that would help score points for perl.