[Perl] Testing for EAGAIN / EWOULDBLOCK on a recv
- by Robert S. Barnes
I'm testing a socket to see if it's still open:
my $dummy = '';
my $ret = recv($sock, $dummy, 1, MSG_DONTWAIT | MSG_PEEK);
if (!defined $ret || (length($dummy) == 0
&& $! != EAGAIN && $! != EWOULDBLOCK )) {
logerr("Broken pipe? ".__LINE__." $!");
} else {
#…