$blocking = $sock->blocking(0) if $timeout; #### 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