This queue is for tickets about the IO-Socket-IP CPAN distribution.

Report information
The Basics
Id:
75783
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

BugTracker
Severity:
Wishlist
Broken in:
0.09
Fixed in:
0.10



Subject: A way to pass getaddrinfo() flags
Suggest either: IO::Socket::IP->new( LocalHost => "127.0.0.1", NumericHost => 1, ... ) or use Socket qw( AI_NUMERICHOST ); IO::Socket::IP->new( GetAddrInfoFlags => AI_NUMERICHOST, ) (because "Flags => ..." feels too generic) Consider also how theabove would interact with the implicit AI_ADDRCONFIG and AI_PASSIVE flags. -- Paul Evans
Fixed upstream. Will be in next release. -- Paul Evans
Subject: rt75783.patch
=== modified file 'lib/IO/Socket/IP.pm' --- lib/IO/Socket/IP.pm 2012-05-02 12:39:19 +0000 +++ lib/IO/Socket/IP.pm 2012-05-08 18:43:05 +0000 @@ -233,6 +233,13 @@ C<getaddrinfo> or the kernel will choose an appropriate value. May be given either in string name or numeric form. +=item GetAddrInfoFlags => INT + +More flags to pass to the C<getaddrinfo()> function. These flags will be +combined with C<AI_ADDRCONFIG>, and if the C<Listen> argument is given, +C<AI_PASSIVE>. For more information see the documentation about +C<getaddrinfo()> in the L<Socket> module. + =item Listen => INT If defined, puts the socket into listening mode where new connections can be @@ -363,7 +370,7 @@ my @localinfos; my @peerinfos; - $hints{flags} = $AI_ADDRCONFIG; + $hints{flags} = ( delete $arg->{GetAddrInfoFlags} || 0 ) | $AI_ADDRCONFIG; # Check for definedness of args, but delete them anyway even if they're # not defined. Then the only remaining keys will be unrecognised ones. === added file 't/17gai-flags.t' --- t/17gai-flags.t 1970-01-01 00:00:00 +0000 +++ t/17gai-flags.t 2012-05-08 18:43:05 +0000 @@ -0,0 +1,57 @@ +#!/usr/bin/perl -w + +use strict; +use Test::More tests => 2; + +use IO::Socket::IP; +use Socket 1.95 qw( + PF_INET SOCK_STREAM IPPROTO_TCP pack_sockaddr_in INADDR_ANY + AI_PASSIVE AI_NUMERICSERV +); + +my $AI_ADDRCONFIG = eval { Socket::AI_ADDRCONFIG() } || 0; + +my @gai_args; +my @gai_rets; + +no strict 'refs'; +no warnings 'redefine'; + +*{"IO::Socket::IP::getaddrinfo"} = sub { + push @gai_args, [ @_ ]; + return @{ shift @gai_rets }; +}; + +@gai_args = (); +@gai_rets = ( + [ "", { + family => PF_INET, + socktype => SOCK_STREAM, + protocol => IPPROTO_TCP, + addr => pack_sockaddr_in( 80, INADDR_ANY ) + } ], +); +IO::Socket::IP->new( LocalPort => "80" ); + +is_deeply( \@gai_args, + [ + [ undef, "80", { flags => AI_PASSIVE|$AI_ADDRCONFIG, socktype => SOCK_STREAM, protocol => IPPROTO_TCP } ], + ], + '@gai_args for LocalPort => "80"' ); + +@gai_args = (); +@gai_rets = ( + [ "", { + family => PF_INET, + socktype => SOCK_STREAM, + protocol => IPPROTO_TCP, + addr => pack_sockaddr_in( 80, INADDR_ANY ) + } ], +); +IO::Socket::IP->new( LocalPort => "80", GetAddrInfoFlags => AI_NUMERICSERV ); + +is_deeply( \@gai_args, + [ + [ undef, "80", { flags => AI_PASSIVE|AI_NUMERICSERV|$AI_ADDRCONFIG, socktype => SOCK_STREAM, protocol => IPPROTO_TCP } ], + ], + '@gai_args for LocalPort => "80", GetAddrInfoFlags => AI_NUMERICSERV' );
Was released in 0.10 but I forgot to close this ticket. -- Paul Evans


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.