1Socket::GetAddrInfo::SoUcskeert6Caopnit(r3i)buted Perl DSooccukmeetn:t:aGteitoAnddrInfo::Socket6api(3)
2
3
4

NAME

6       "Socket::GetAddrInfo::Socket6api" - Provide Socket::GetAddrInfo
7       functions using Socket6 API
8

SYNOPSIS

10        use Socket qw( AF_UNSPEC SOCK_STREAM );
11        use Socket::GetAddrInfo::Socket6api qw( getaddrinfo getnameinfo );
12
13        my $sock;
14
15        my @res = getaddrinfo( "www.google.com", "www", AF_UNSPEC, SOCK_STREAM );
16
17        die "Cannot resolve name - $res[0]" if @res == 1;
18
19        while( @res >= 5 ) {
20           my ( $family, $socktype, $protocol, $addr, undef ) = splice @res, 0, 5, ();
21
22           $sock = IO::Socket->new();
23           $sock->socket( $family, $socktype, $protocol ) or
24             undef $sock, next;
25
26           $sock->connect( $addr ) or undef $sock, next;
27
28           last;
29        }
30
31        if( $sock ) {
32           my ( $host, $service ) = getnameinfo( $sock->peername );
33           print "Connected to $host:$service\n" if defined $host;
34        }
35

DESCRIPTION

37       Socket::GetAddrInfo provides the functions of "getaddrinfo" and
38       "getnameinfo" using a convenient interface where hints and address
39       structures are represented as hashes. Socket6 also provides these
40       functions, in a form taking and returning flat lists of values.
41
42       This module wraps the functions provided by "Socket::GetAddrInfo" to
43       provide them in an identical API to "Socket6". It is intended to stand
44       as a utility for existing code written for the "Socket6" API to use
45       these functions instead.
46

FUNCTIONS

48   @res = getaddrinfo( $host, $service, $family, $socktype, $protocol, $flags
49       )
50       This version of the API takes the hints values as separate ordered
51       parameters.  Unspecified parameters should be passed as 0.
52
53       If successful, this function returns a flat list of values, five for
54       each returned address structure. Each group of five elements will
55       contain, in order, the "family", "socktype", "protocol", "addr" and
56       "canonname" values of the address structure.
57
58       If unsuccessful, it will return a single value, containing the string
59       error message. To remain compatible with the "Socket6" interface, this
60       value does not have the error integer part.
61
62   ( $host, $service ) = getnameinfo( $addr, $flags )
63       This version of the API returns only the host name and service name, if
64       successfully resolved. On error, it will return an empty list. To
65       remain compatible with the "Socket6" interface, no error information
66       will be supplied.
67

AUTHOR

69       Paul Evans <leonerd@leonerd.org.uk>
70
71
72
73perl v5.34.0                      2021-07-22Socket::GetAddrInfo::Socket6api(3)
Impressum