Yes! You are correct sir! Drawing from c experience, I went with somethink like this:
#Passive check for down socket
my $sin = "";
vec($sin, fileno(SESSION),1 ) = 1;
my $nfound = select($sin, undef, undef, .01);
if ($nfound != 0){
if( eof(SESSION) == 1 ){
die "Socket is dead on passive check\n";
}
}
Here I told select to time out after .01 seconds. If the connection goes down (gracefully) then $nfound returns something greater than 0 (the disconnect packet?) but an eof on the socket then determines that socket handle SESSION is at EOF and so the program dies, or whatever.
It is worth noting, however, that if the connection does NOT go down gracefule, like the remote network cable comes unplugged, then this does not work as expected. Select WILL return 0.
|