… | |
… | |
1013 | $state{to} = AE::timer $timeout, 0, sub { |
1013 | $state{to} = AE::timer $timeout, 0, sub { |
1014 | $! = Errno::ETIMEDOUT; |
1014 | $! = Errno::ETIMEDOUT; |
1015 | $state{next}(); |
1015 | $state{next}(); |
1016 | } if $timeout; |
1016 | } if $timeout; |
1017 | |
1017 | |
1018 | # now connect |
1018 | # now connect |
1019 | if ( |
1019 | if ( |
1020 | (connect $state{fh}, $sockaddr) |
1020 | (connect $state{fh}, $sockaddr) |
1021 | || ($! == Errno::EINPROGRESS # POSIX |
1021 | || ($! == Errno::EINPROGRESS # POSIX |
1022 | || $! == Errno::EWOULDBLOCK |
1022 | || $! == Errno::EWOULDBLOCK |
1023 | # WSAEINPROGRESS intentionally not checked - it means something else entirely |
1023 | # WSAEINPROGRESS intentionally not checked - it means something else entirely |
1024 | || $! == AnyEvent::Util::WSAEINVAL # not convinced, but doesn't hurt |
1024 | || $! == AnyEvent::Util::WSAEINVAL # not convinced, but doesn't hurt |
1025 | || $! == AnyEvent::Util::WSAEWOULDBLOCK) |
1025 | || $! == AnyEvent::Util::WSAEWOULDBLOCK) |
1026 | ) { |
1026 | ) { |
1027 | $state{ww} = AE::io $state{fh}, 1, sub { |
1027 | $state{ww} = AE::io $state{fh}, 1, sub { |
|
|
1028 | return unless exists $state{fh}; |
|
|
1029 | |
1028 | # we are connected, or maybe there was an error |
1030 | # we are connected, or maybe there was an error |
1029 | if (my $sin = getpeername $state{fh}) { |
1031 | if (my $sin = getpeername $state{fh}) { |
1030 | my ($port, $host) = unpack_sockaddr $sin; |
1032 | my ($port, $host) = unpack_sockaddr $sin; |
1031 | |
1033 | |
1032 | delete $state{ww}; delete $state{to}; |
1034 | delete $state{ww}; delete $state{to}; |