From: Gurusamy Sarathy Date: Tue, 22 Feb 2000 04:45:57 +0000 (+0000) Subject: use same treatment for EINVAL as for ETIMEDOUT X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e541f5e7702d28bc5ed83b5b23cf57d476b829cb;p=p5sagit%2Fp5-mst-13.2.git use same treatment for EINVAL as for ETIMEDOUT p4raw-id: //depot/perl@5188 --- diff --git a/ext/IO/lib/IO/Socket/INET.pm b/ext/IO/lib/IO/Socket/INET.pm index af64c96..696e988 100644 --- a/ext/IO/lib/IO/Socket/INET.pm +++ b/ext/IO/lib/IO/Socket/INET.pm @@ -12,11 +12,13 @@ use IO::Socket; use Socket; use Carp; use Exporter; -use Errno qw(EINVAL); # EINVAL appears portable +use Errno; @ISA = qw(IO::Socket); $VERSION = "1.25"; +my $EINVAL = exists(&Errno::EINVAL) ? Errno::EINVAL() : 1; + IO::Socket::INET->register_domain( AF_INET ); my %socket_type = ( tcp => SOCK_STREAM, @@ -117,7 +119,7 @@ sub configure { $laddr = defined $laddr ? inet_aton($laddr) : INADDR_ANY; - return _error($sock, EINVAL, "Bad hostname '",$arg->{LocalAddr},"'") + return _error($sock, $EINVAL, "Bad hostname '",$arg->{LocalAddr},"'") unless(defined $laddr); $arg->{PeerAddr} = $arg->{PeerHost} @@ -139,7 +141,7 @@ sub configure { if(defined $raddr) { @raddr = $sock->_get_addr($raddr, $arg->{MultiHomed}); - return _error($sock, EINVAL, "Bad hostname '",$arg->{PeerAddr},"'") + return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'") unless @raddr; } @@ -169,13 +171,13 @@ sub configure { $raddr = shift @raddr; - return _error($sock, EINVAL, 'Cannot determine remote port') + return _error($sock, $EINVAL, 'Cannot determine remote port') unless($rport || $type == SOCK_DGRAM || $type == SOCK_RAW); last unless($type == SOCK_STREAM || defined $raddr); - return _error($sock, EINVAL, "Bad hostname '",$arg->{PeerAddr},"'") + return _error($sock, $EINVAL, "Bad hostname '",$arg->{PeerAddr},"'") unless defined $raddr; # my $timeout = ${*$sock}{'io_socket_timeout'}; @@ -192,7 +194,7 @@ sub configure { # if ($timeout) { # my $new_timeout = $timeout - (time() - $before); # return _error($sock, -# (exists(&Errno::ETIMEDOUT) ? &Errno::ETIMEDOUT : EINVAL), +# (exists(&Errno::ETIMEDOUT) ? Errno::ETIMEDOUT() : $EINVAL), # "Timeout") if $new_timeout <= 0; # ${*$sock}{'io_socket_timeout'} = $new_timeout; # }