use IO::Select; my $sock_read_hdl = IO::Select->new(); $sock_read_hdl->add($oSocket); # Block here until message arrives my ($read_ready) = IO::Select->select($sock_read_hdl, undef, undef, undef); # Now we are ready to read message. Note: $read_ready->[0] == $oSocket here. eval { ... } or die $@; # As pointed out by ikegami, thanks.