I tracked it down to an attempt to put the socket in non-blocking mode in IO::Socket:
$blocking = $sock->blocking(0) if $timeout;
blocking returns undef. (But $! is not set. Does that mean that switching to non-blocking didn't fail? The docs define failure as returning undef and setting $!.) The timeout mechanism relies on using non-blocking mode, and the results are consistent on this method failing or the following connect ignoring the non-blocking mode.
I wish I could go deeper -- does Perl simply ignore non-blocking on sockets in Windows, or does Windows not support it -- but I'm not sure how.
Update: Here's a cleaned up version of the program I used to test my assertions:
use strict; use warnings; use IO::Socket; sub show_blocking_result { my ($blocking) = @_; die("Error switching to non-blocking: $!\n") if not defined $blocking; printf("Was previously: %s\n", ($blocking ? "blocking" : "non-blocking"), ); } my $sock = new IO::Socket::INET( PeerAddr => "www.perlmonks.org", PeerPort => 80, Proto => 'tcp', ); die("Error connecting: $!\n") if not defined $sock; # We didn't turn off blocking mode, # so the following should return true. show_blocking_result($sock->blocking(0)); # Should return false, but presumably defined. show_blocking_result($sock->blocking(1)); __END__ Windows ------- Error switching to non-blocking: FreeBSD ------- Was previously: blocking Was previously: non-blocking
In reply to Re: nbtstat.pl fails for non-windows IP
by ikegami
in thread nbtstat.pl fails for non-windows IP
by sgrey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |