Socket select in Perl

David Smith DavidSmith at
Thu Feb 17 16:58:20 MST 2005

I have a socket that I created with 'new IO::Socket::INET( ... )', which
works great for me. Now, I want to do a C-style select on the socket to
check if there is data to read on the socket before blocking to read from
it. Is this possible?

Here's what I'm working for in non-compiling Perl code:

my $timeout = 500; # (in ms)
if( select( $socket, $timeout ) ) {
   # read more from the socket
} else {
   # move on to something else

Perl's built-in select() function doesn't quite look like what I want. I
think IO::Select may be the trick, but it seems like overkill when I just
have one socket (and not a set of handles to multiplex). Can anyone shed
light on this struggling Perlmonk wannabe?

Thanks in advance.


More information about the PLUG mailing list