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::Strict(3pm)			User Contributed Perl Documentation			  Socket::GetAddrInfo::Strict(3pm)

NAME
"Socket::GetAddrInfo::Strict" - Provide Socket::GetAddrInfo functions which throw exceptions SYNOPSIS
use Socket qw( SOCK_STREAM ); use Socket::GetAddrInfo::Strict qw( getaddrinfo getnameinfo ); use IO::Socket; my $sock; my %hints = ( socktype => SOCK_STREAM ); my @res = getaddrinfo( "www.google.com", "www", \%hints ); while( my $ai = shift @res ) { $sock = IO::Socket->new(); $sock->socket( $ai->{family}, $ai->{socktype}, $ai->{protocol} ) or undef $sock, next; $sock->connect( $ai->{addr} ) or undef $sock, next; last; } if( $sock ) { my ( $host, $service ) = getnameinfo( $sock->peername ); print "Connected to $host:$service "; } DESCRIPTION
Socket::GetAddrInfo provides the functions of "getaddrinfo" and "getnameinfo", which return lists whose first element is error value, or false indicating no error occured. This module wraps the functions provided by "Socket::GetAddrInfo" to check this error value, and throw an exception (using "die") if an error occured. If not, then the remaining values are returned as normal. This can simplify the logic of a program which otherwise simply throws its own exception on failure anyway. FUNCTIONS
@res = getaddrinfo( $host, $service, $hints ) After a successful lookup, returns the list of address structures, as documented in Socket::GetAddrInfo. If the lookup fails, an exception containing the string form of the error is thrown instead. ( $host, $service ) = getnameinfo( $addr, $flags, $xflags ) After a successful lookup, returns the host and service name, as documented in Socket::GetAddrInfo. If the lookup fails, an exception containing the string form of the error is thrown instead. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-06-08 Socket::GetAddrInfo::Strict(3pm)
Man Page