my $timeout = ${*$sock}{'io_socket_timeout'};
my $err;
my $blocking;
- $blocking = $sock->blocking(0) if $timeout;
+ $blocking = $sock->blocking(0) if $timeout;
if (!connect($sock, $addr)) {
if (defined $timeout && $!{EINPROGRESS}) {
require IO::Select;
$err = $! || (exists &Errno::ETIMEDOUT ? &Errno::ETIMEDOUT : 1);
$@ = "connect: timeout";
}
- elsif(!connect($sock,$addr) && not $!{EISCONN}) {
+ elsif (!connect($sock,$addr) && not $!{EISCONN}) {
# Some systems refuse to re-connect() to
# an already open socket and set errno to EISCONN.
$err = $!;
$@ = "connect: $!";
}
}
- else {
+ elsif ($blocking || !$!{EINPROGRESS}) {
$err = $!;
$@ = "connect: $!";
}
or return _error($sock, $!, $@);
}
+ $sock->blocking($arg->{Blocking}) if defined $arg->{Blocking};
+
$proto ||= (getprotobyname('tcp'))[2];
my $pname = (getprotobynumber($proto))[0];
ReusePort Set SO_REUSEPORT before binding
Timeout Timeout value for various operations
MultiHomed Try all adresses for multi-homed hosts
-
+ Blocking Determine if connection will be blocking mode
If C<Listen> is defined then a listen socket is created, else if the
socket type, which is derived from the protocol, is SOCK_STREAM then
If the constructor is only passed a single argument, it is assumed to
be a C<PeerAddr> specification.
+If C<Blocking> is set to 0, the connection will be in nonblocking mode.
+If not specified it defaults to 1 (blocking mode).
+
Examples:
$sock = IO::Socket::INET->new(PeerAddr => 'www.perl.org',