GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  SOCKET::GETADDRINFO::STRICT (3)

.ds Aq ’

NAME

"Socket::GetAddrInfo::Strict" - Provide Socket::GetAddrInfo functions which throw exceptions

CONTENTS

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\n";
 }



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

CW@res = getaddrinfo( CW$host, CW$service, CW$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.

( CW$host, CW$service ) = getnameinfo( CW$addr, CW$flags, CW$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>
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 SOCKET::GETADDRINFO::STRICT (3) 2016-03-17

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.