http://www.perlmonks.org?node_id=184851


in reply to What is the easy way to check if the socket has data to read, before do a read()

Use IO::Select, pass the socket handle to it and use can_read method to detemine if the handle is ready, here's snippet from perldoc:
use IO::Socket; use IO::Select; $lsn = new IO::Socket::INET(Listen => 1, LocalPort => 8080); $sel = new IO::Select( $lsn ); while(@ready = $sel->can_read) { ... }
  • Comment on Re: What is the easy way to check if the socket has data to read, before do a read()
  • Download Code