From: Benjamin Low Date: Fri, 8 Jan 1999 14:36:53 +0000 (+1100) Subject: Re: [Fwd: IO::Socket::connect and blocking] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=00fdd80d96a7c61ee9d4b02db269b54430a119de;p=p5sagit%2Fp5-mst-13.2.git Re: [Fwd: IO::Socket::connect and blocking] Message-ID: <36957D55.1D65A0B2@unsw.edu.au> p4raw-id: //depot/perl@2868 --- diff --git a/ext/IO/lib/IO/Socket.pm b/ext/IO/lib/IO/Socket.pm index 894190f..0bdf2ff 100644 --- a/ext/IO/lib/IO/Socket.pm +++ b/ext/IO/lib/IO/Socket.pm @@ -22,7 +22,7 @@ require IO::Socket::UNIX; @ISA = qw(IO::Handle); -$VERSION = "1.25"; +$VERSION = "1.251"; sub import { my $pkg = shift; @@ -101,39 +101,34 @@ sub connect { my $addr = shift; my $timeout = ${*$sock}{'io_socket_timeout'}; - eval { - my $blocking = 0; + my $blocking; + $blocking = $sock->blocking(0) if $timeout; + eval { croak 'connect: Bad address' if(@_ == 2 && !defined $_[1]); - $blocking = $sock->blocking(0) - if($timeout); - unless(connect($sock, $addr)) { if($timeout && ($! == &IO::EINPROGRESS)) { require IO::Select; my $sel = new IO::Select $sock; - $sock->blocking(1) - if($blocking); - unless($sel->can_write($timeout) && defined($sock->peername)) { - undef $sock; croak "connect: timeout"; } } else { - undef $sock; croak "connect: $!"; } } - $sock->blocking(1) - if($sock && $blocking); }; - $sock; + my $ret = $@ ? undef : $sock; + + $sock->blocking($blocking) if $timeout; + + $ret; } sub bind {