> [EMAIL PROTECTED] - Thu May 31 05:01:54 2001]:
> 
>   #!/usr/bin/perl
> 
>   my $addr = "192.168.2.2";  # or any non-reachable address
>   my $port = 5010;
> 
>   use IO::Socket;
> 
>   my $sock = IO::Socket::INET->new(PeerAddr=>$addr,
>                                    PeerPort=>$port,
>                                    Proto=>'tcp',
>                                    Timeout => 3);
> 
>   print "Connect failed: [EMAIL PROTECTED]" unless ($sock);
> 
> 
> produces:
> 
>   Connect failed: IO::Socket::INET:
> 
> 
> Digging into the code (IO::Socket::INET line 169), I see:
> 
>         return _error($sock,"$!")
>             unless @raddr;
> 
> (i.e. set $@ to "IO::Socket::INET: $!" and return undef).  However,
> in the case of a failed IO::Socket::connect() call (i.e. bad address,
> failed connect(2), or timeout), the connect call dies via 'croak' in
> an eval, so $@ (not $!) contains the error message.
> 
> I changed the line to
> 
>           return _error($sock, $! ? "$!" : $@)
>             unless @raddr;
> 
> , which seems to work.

I am unable to reproduce this problem with 5.4.5, 5.5.3, 5.6.2 or 5.8.6
on OS X.  I don't have a Linux machine handy with a 5.6.x to reproduce.
 So I can't confirm that the bug is fixed, but there does seem to be
code in IO::Socket::INET to take into account both $! and $@ in each error.

Anyone care to confirm?

Reply via email to