diff options
Diffstat (limited to 'Master/tlpkg/tlperl/lib/IO/Socket.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/IO/Socket.pm | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Master/tlpkg/tlperl/lib/IO/Socket.pm b/Master/tlpkg/tlperl/lib/IO/Socket.pm index aa3c9add78c..c78aeecc1a0 100644 --- a/Master/tlpkg/tlperl/lib/IO/Socket.pm +++ b/Master/tlpkg/tlperl/lib/IO/Socket.pm @@ -24,7 +24,7 @@ require IO::Socket::UNIX if ($^O ne 'epoc' && $^O ne 'symbian'); @ISA = qw(IO::Handle); -$VERSION = "1.36"; +$VERSION = "1.38"; @EXPORT_OK = qw(sockatmark); @@ -135,11 +135,13 @@ sub connect { $@ = "connect: timeout"; } elsif (!connect($sock,$addr) && - not ($!{EISCONN} || ($! == 10022 && $^O eq 'MSWin32')) + not ($!{EISCONN} || ($^O eq 'MSWin32' && + ($! == (($] < 5.019004) ? 10022 : Errno::EINVAL)))) ) { # Some systems refuse to re-connect() to # an already open socket and set errno to EISCONN. - # Windows sets errno to WSAEINVAL (10022) + # Windows sets errno to WSAEINVAL (10022) (pre-5.19.4) or + # EINVAL (22) (5.19.4 onwards). $err = $!; $@ = "connect: $!"; } @@ -497,8 +499,23 @@ C<use> declaration will fail at compile time. =item connected -If the socket is in a connected state the peer address is returned. -If the socket is not in a connected state then undef will be returned. +If the socket is in a connected state, the peer address is returned. If the +socket is not in a connected state, undef is returned. + +Note that connected() considers a half-open TCP socket to be "in a connected +state". Specifically, connected() does not distinguish between the +B<ESTABLISHED> and B<CLOSE-WAIT> TCP states; it returns the peer address, +rather than undef, in either case. Thus, in general, connected() cannot +be used to reliably learn whether the peer has initiated a graceful shutdown +because in most cases (see below) the local TCP state machine remains in +B<CLOSE-WAIT> until the local application calls shutdown() or close(); +only at that point does connected() return undef. + +The "in most cases" hedge is because local TCP state machine behavior may +depend on the peer's socket options. In particular, if the peer socket has +SO_LINGER enabled with a zero timeout, then the peer's close() will generate +a RST segment, upon receipt of which the local TCP transitions immediately to +B<CLOSED>, and in that state, connected() I<will> return undef. =item protocol |