Query: socket::getaddrinfo::strict
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
Socket::GetAddrInfo::Strict(3pm) User Contributed Perl Documentation Socket::GetAddrInfo::Strict(3pm)NAME"Socket::GetAddrInfo::Strict" - Provide Socket::GetAddrInfo functions which throw exceptionsSYNOPSISuse 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 "; }DESCRIPTIONSocket::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.AUTHORPaul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-06-08 Socket::GetAddrInfo::Strict(3pm)
Related Man Pages |
---|
io::socket::inet(3pm) - centos |
coro::socket(3pm) - debian |
io::async::connector(3pm) - debian |
io::socket::ip(3pm) - debian |
socket::getaddrinfo::strict(3pm) - debian |
Similar Topics in the Unix Linux Community |
---|
Need Help Regarding Socket Programming |
Performance issue with C++ ,Socket |
netstat error(getnameinfo failed) |
How to set DNS lookup type for getaddrinfo()? |
Socket Programming in Perl |