The code fragment is: # this is called to connect to remote host sub connect { my $pack = shift; my ($host,$port) = @_; my $sock = IO::Socket::INET->new(Proto => 'tcp', Type => SOCK_STREAM); return unless $sock; $sock->blocking(0); my $addr = sockaddr_in($port,inet_aton($host)); my $result = $sock->connect($addr); return $sock if $result; # return the socket if connected immediately return $sock if $! == EINPROGRESS; # or if it's in progress return; # return undef on other errors }