summaryrefslogtreecommitdiff
path: root/cpan/IO-Socket-IP/lib
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2014-02-25 11:04:29 +0000
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2014-02-25 11:41:12 +0000
commitf728ea121a319b376bb24026acdaa56996bffb02 (patch)
tree91382826587d84096c1db495bdcec80f0be05b87 /cpan/IO-Socket-IP/lib
parent845ab12d77c07580053486e445977dc895d747f8 (diff)
downloadperl-f728ea121a319b376bb24026acdaa56996bffb02.tar.gz
Update IO-Socket-IP to CPAN version 0.29
[DELTA] 0.29 2014/02/24 16:06:29 [BUGFIXES] * Workaround for OSes that disobey AI_ADDRCONFIG and yield AIs on families the kernel will not support anyway (e.g. HPUX) * Workaround for OSes that lack getprotobyname() (e.g. Android)
Diffstat (limited to 'cpan/IO-Socket-IP/lib')
-rw-r--r--cpan/IO-Socket-IP/lib/IO/Socket/IP.pm30
1 files changed, 19 insertions, 11 deletions
diff --git a/cpan/IO-Socket-IP/lib/IO/Socket/IP.pm b/cpan/IO-Socket-IP/lib/IO/Socket/IP.pm
index 44d057f6aa..30e0464d70 100644
--- a/cpan/IO-Socket-IP/lib/IO/Socket/IP.pm
+++ b/cpan/IO-Socket-IP/lib/IO/Socket/IP.pm
@@ -7,7 +7,7 @@ package IO::Socket::IP;
# $VERSION needs to be set before use base 'IO::Socket'
# - https://rt.cpan.org/Ticket/Display.html?id=92107
BEGIN {
- $VERSION = '0.28';
+ $VERSION = '0.29';
}
use strict;
@@ -35,6 +35,9 @@ use Errno qw( EINVAL EINPROGRESS EISCONN );
use constant HAVE_MSWIN32 => ( $^O eq "MSWin32" );
+# At least one OS (Android) is known not to have getprotobyname()
+use constant HAVE_GETPROTOBYNAME => defined eval { getprotobyname( "tcp" ) };
+
my $IPv6_re = do {
# translation of RFC 3986 3.2.2 ABNF to re
my $IPv4address = do {
@@ -394,7 +397,9 @@ sub _io_socket_ip__configure
if( defined( my $proto = $arg->{Proto} ) ) {
unless( $proto =~ m/^\d+$/ ) {
- my $protonum = getprotobyname( $proto );
+ my $protonum = HAVE_GETPROTOBYNAME
+ ? getprotobyname( $proto )
+ : eval { Socket->${\"IPPROTO_\U$proto"}() };
defined $protonum or croak "Unrecognised protocol $proto";
$proto = $protonum;
}
@@ -518,24 +523,27 @@ sub _io_socket_ip__configure
if( !@infos ) {
# If there was a Family hint then create a plain unbound, unconnected socket
+ if( defined $hints{family} ) {
+ @infos = ( {
+ family => $hints{family},
+ socktype => $hints{socktype},
+ protocol => $hints{protocol},
+ } );
+ }
# If there wasn't, use getaddrinfo()'s AI_ADDRCONFIG side-effect to guess a
# suitable family first.
- if( !defined $hints{family} ) {
- my ( $err, $addrinfo ) = getaddrinfo( "", "0", \%hints );
+ else {
+ ( my $err, @infos ) = getaddrinfo( "", "0", \%hints );
if( $err ) {
$@ = "$err";
$! = EINVAL;
return;
}
- $hints{family} = $addrinfo->{family};
+ # We'll take all the @infos anyway, because some OSes (HPUX) are known to
+ # ignore the AI_ADDRCONFIG hint and return AF_INET6 even if they don't
+ # support them
}
-
- @infos = ( {
- family => $hints{family},
- socktype => $hints{socktype},
- protocol => $hints{protocol},
- } );
}
# In the nonblocking case, caller will be calling ->setup multiple times.