Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

socket::getaddrinfo::socket6api(3pm) [debian man page]

Socket::GetAddrInfo::Socket6api(3pm)			User Contributed Perl Documentation		      Socket::GetAddrInfo::Socket6api(3pm)

NAME
"Socket::GetAddrInfo::Socket6api" - Provide Socket::GetAddrInfo functions using Socket6 API SYNOPSIS
use Socket qw( AF_UNSPEC SOCK_STREAM ); use Socket::GetAddrInfo::Socket6api qw( getaddrinfo getnameinfo ); my $sock; my @res = getaddrinfo( "www.google.com", "www", AF_UNSPEC, SOCK_STREAM ); die "Cannot resolve name - $res[0]" if @res == 1; while( @res >= 5 ) { my ( $family, $socktype, $protocol, $addr, undef ) = splice @res, 0, 5, (); $sock = IO::Socket->new(); $sock->socket( $family, $socktype, $protocol ) or undef $sock, next; $sock->connect( $addr ) or undef $sock, next; last; } if( $sock ) { my ( $host, $service ) = getnameinfo( $sock->peername ); print "Connected to $host:$service " if defined $host; } DESCRIPTION
Socket::GetAddrInfo provides the functions of "getaddrinfo" and "getnameinfo" using a convenient interface where hints and address structures are represented as hashes. Socket6 also provides these functions, in a form taking and returning flat lists of values. This module wraps the functions provided by "Socket::GetAddrInfo" to provide them in an identical API to "Socket6". It is intended to stand as a utility for existing code written for the "Socket6" API to use these functions instead. FUNCTIONS
@res = getaddrinfo( $host, $service, $family, $socktype, $protocol, $flags ) This version of the API takes the hints values as separate ordered parameters. Unspecified parameters should be passed as 0. If successful, this function returns a flat list of values, five for each returned address structure. Each group of five elements will contain, in order, the "family", "socktype", "protocol", "addr" and "canonname" values of the address structure. If unsuccessful, it will return a single value, containing the string error message. To remain compatible with the "Socket6" interface, this value does not have the error integer part. ( $host, $service ) = getnameinfo( $addr, $flags ) This version of the API returns only the host name and service name, if successfully resolved. On error, it will return an empty list. To remain compatible with the "Socket6" interface, no error information will be supplied. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-06-08 Socket::GetAddrInfo::Socket6api(3pm)

Check Out this Related Man Page

Socket::GetAddrInfo::Emul(3pm)				User Contributed Perl Documentation			    Socket::GetAddrInfo::Emul(3pm)

NAME
"Socket::GetAddrInfo::Emul" - Pure Perl emulation of "getaddrinfo" and "getnameinfo" using IPv4-only legacy resolvers DESCRIPTION
"Socket::GetAddrInfo" attempts to provide the "getaddrinfo" and "getnameinfo" functions by some XS code that calls the real functions in libc. If for some reason this cannot be done; either there is no C compiler, or libc does not provide these functions, then they will be emulated using the legacy resolvers "gethostbyname", etc... These emulations are not a complete replacement of the real functions, because they only support IPv4 (the "AF_INET" socket family). In this case, the following restrictions will apply. getaddrinfo o If the "family" hint is supplied, it must be "AF_INET". Any other value will result in an error thrown by "croak". o The only supported "flags" hint values are "AI_PASSIVE", "AI_CANONNAME", "AI_NUMERICSERV" and "AI_NUMERICHOST". The flags "AI_V4MAPPED" and "AI_ALL" are recognised but ignored, as they do not apply to "AF_INET" lookups. Since this function only returns "AF_INET" addresses, it does not need to probe the system for configured addresses in other families, so the "AI_ADDRCONFIG" flag is also ignored. Note that "AI_NUMERICSERV" is an extension not defined by RFC 2553, but is provided by most OSes. It is possible (though unlikely) that even the native XS implementation does not recognise this constant. getnameinfo o If the sockaddr family of $addr is anything other than "AF_INET", an error will be thrown with "croak". o The only supported $flags values are "NI_NUMERICHOST", "NI_NUMERICSERV", "NI_NOFQDN", "NI_NAMEREQD" and "NI_DGRAM". IDN SUPPORT
This pure-perl emulation provides the IDN constants such as "AI_IDN" and "NI_IDN", but the "getaddrinfo" and "getnameinfo" functions will croak if passed these flags. This should allow a program to probe for their support, and fall back to some other behaviour instead. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-06-08 Socket::GetAddrInfo::Emul(3pm)
Man Page