Skip to content

Commit

Permalink
Support emulation of AI_NUMERICSERV even though it's not strictly RFC…
Browse files Browse the repository at this point in the history
… 2553, because most OSes support it anyway, and it's easy to do
  • Loading branch information
leonerd authored and obra committed Jan 5, 2011
1 parent fd74a74 commit 2a59724
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/Socket/Socket.pm
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ if( !defined &getaddrinfo ) {
AI_PASSIVE => 1,
AI_CANONNAME => 2,
AI_NUMERICHOST => 4,
# RFC 2553 doesn't define this but Linux does - lets be nice and
# provide it since we can
AI_NUMERICSERV => 1024,

EAI_BADFLAGS => -1,
EAI_NONAME => -2,
Expand Down Expand Up @@ -663,6 +666,7 @@ sub fake_getaddrinfo
my $flag_passive = $flags & AI_PASSIVE(); $flags &= ~AI_PASSIVE();
my $flag_canonname = $flags & AI_CANONNAME(); $flags &= ~AI_CANONNAME();
my $flag_numerichost = $flags & AI_NUMERICHOST(); $flags &= ~AI_NUMERICHOST();
my $flag_numericserv = $flags & AI_NUMERICSERV(); $flags &= ~AI_NUMERICSERV();

$flags == 0 or return fake_makeerr( EAI_BADFLAGS() );

Expand All @@ -689,6 +693,7 @@ sub fake_getaddrinfo
}

if( $service ne "" and $service !~ m/^\d+$/ ) {
return fake_makeerr( EAI_NONAME() ) if( $flag_numericserv );
getservbyname( $service, $protname ) or return fake_makeerr( EAI_SERVICE() );
}

Expand Down

0 comments on commit 2a59724

Please sign in to comment.