summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorBenjamin Low <b.d.low@unsw.edu.au>1999-01-09 01:36:53 +1100
committerGurusamy Sarathy <gsar@cpan.org>1999-02-11 10:42:44 +0000
commit00fdd80d96a7c61ee9d4b02db269b54430a119de (patch)
tree53763c0b6a24af042a96a5a2eb1bc0212508ba14 /ext
parentadc882cf99d008e01c073cdfa1fde20ef9820798 (diff)
downloadperl-00fdd80d96a7c61ee9d4b02db269b54430a119de.tar.gz
Re: [Fwd: IO::Socket::connect and blocking]
Message-ID: <36957D55.1D65A0B2@unsw.edu.au> p4raw-id: //depot/perl@2868
Diffstat (limited to 'ext')
-rw-r--r--ext/IO/lib/IO/Socket.pm23
1 files changed, 9 insertions, 14 deletions
diff --git a/ext/IO/lib/IO/Socket.pm b/ext/IO/lib/IO/Socket.pm
index 894190fbee..0bdf2ff989 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 {