1Socket6(3)            User Contributed Perl Documentation           Socket6(3)
2
3
4

NAME

6       Socket6 - IPv6 related part of the C socket.h defines and structure
7       manipulators
8

SYNOPSIS

10           use Socket;
11           use Socket6;
12
13           @res = getaddrinfo('hishost.com', 'daytime', AF_UNSPEC, SOCK_STREAM);
14           $family = -1;
15           while (scalar(@res) >= 5) {
16               ($family, $socktype, $proto, $saddr, $canonname, @res) = @res;
17
18               ($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
19               print STDERR "Trying to connect to $host port $port...\n";
20
21               socket(Socket_Handle, $family, $socktype, $proto) || next;
22               connect(Socket_Handle, $saddr) && last;
23
24               close(Socket_Handle);
25               $family = -1;
26           }
27
28           if ($family != -1) {
29               print STDERR "connected to $host port $port\n";
30           } else {
31               die "connect attempt failed\n";
32           }
33

DESCRIPTION

35       This module provides glue routines to the various IPv6 functions.
36
37       If you use the Socket6 module, be sure to specify "use Socket" as well
38       as "use Socket6".
39
40       Functions supplied are:
41
42       inet_pton FAMILY, TEXT_ADDRESS
43               This function takes an IP address in presentation (or string) format
44               and converts it into numeric (or binary) format.
45               The type of IP address conversion (IPv4 versus IPv6) is controlled
46               by the FAMILY argument.
47
48       inet_ntop FAMILY, BINARY_ADDRESS
49               This function takes an IP address in numeric (or binary) format
50               and converts it into presentation (or string) format
51               The type of IP address conversion (IPv4 versus IPv6) is controlled
52               by the FAMILY argument.
53
54       pack_sockaddr_in6 PORT, ADDR
55               This function takes two arguments: a port number, and a 16-octet
56               IPv6 address structure (as returned by inet_pton()).
57               It returns the sockaddr_in6 structure with these arguments packed
58               into their correct fields, as well as the AF_INET6 family.
59               The other fields are not set and their values should not be relied upon.
60
61       pack_sockaddr_in6_all PORT, FLOWINFO, ADDR, SCOPEID
62               This function takes four arguments: a port number, a 16-octet
63               IPv6 address structure (as returned by inet_pton), any
64               special flow information, and any specific scope information.
65               It returns a complete sockaddr_in6 structure with these arguments packed
66               into their correct fields, as well as the AF_INET6 family.
67
68       unpack_sockaddr_in6 NAME
69               This function takes a sockaddr_in6 structure (as returned by
70               pack_sockaddr_in6()) and returns a list of two elements:
71               the port number and the 16-octet IP address.
72               This function will croak if it determines it has not been
73               passed an IPv6 structure.
74
75       unpack_sockaddr_in6_all NAME
76               This function takes a sockaddr_in6 structure (as returned by
77               pack_sockaddr_in6()) and returns a list of four elements:
78               the port number, the flow information, the 16-octet IP address,
79               and the scope information.
80               This function will croak if it determines it has not been
81               passed an IPv6 structure.
82
83       gethostbyname2 HOSTNAME, FAMILY
84               This function doesn't supported.
85
86       getaddrinfo NODENAME, SERVICENAME, [FAMILY, SOCKTYPE, PROTOCOL, FLAGS]
87               This function converts node names to addresses and service names
88               to port numbers.
89               If the NODENAME argument is not a false value,
90               then a nodename to address lookup is performed;
91               otherwise a service name to port number lookup is performed.
92               At least one of NODENAME and SERVICENAME must have a true value.
93
94               If the lookup is successful, a list consisting of multiples of
95               five elements is returned.
96               Each group of five elements consists of the address family,
97               socket type, protocol, 16-octet IP address, and the canonical
98               name (undef if the node name passed is already the canonical name).
99
100               The arguments FAMILY, SOCKTYPE, PROTOCOL, and FLAGS are all optional.
101
102               This function will croak if it determines it has not been
103               passed an IPv6 structure.
104
105               If the lookup is unsuccessful, the function returns a single scalar.
106               This will contain the string version of that error in string context,
107               and the numeric value in numeric context.
108
109       getnameinfo NAME, [FLAGS]
110               This function takes a socket address structure. If successful, it returns
111               two strings containing the node name and service name.
112
113               The optional FLAGS argument controls what kind of lookup is performed.
114
115               If the lookup is unsuccessful, the function returns a single scalar.
116               This will contain the string version of that error in string context,
117               and the numeric value in numeric context.
118
119       getipnodebyname HOST, [FAMILY, FLAGS]
120               This function takes either a node name or an IP address string
121               and performs a lookup on that name (or conversion of the string).
122               It returns a list of five elements: the canonical host name,
123               the address family, the length in octets of the IP addresses
124               returned, a reference to a list of IP address structures, and
125               a reference to a list of aliases for the host name.
126
127               The arguments FAMILY and FLAGS are optional.
128               Note: This function does not handle IPv6 scope identifiers,
129               and should be used with care.
130               And, this function was deprecated in RFC3493.
131               The getnameinfo function should be used instead.
132
133       getipnodebyaddr FAMILY, ADDRESS
134               This function takes an IP address family and an IP address structure
135               and performs a reverse lookup on that address.
136               It returns a list of five elements: the canonical host name,
137               the address family, the length in octets of the IP addresses
138               returned, a reference to a list of IP address structures, and
139               a reference to a list of aliases for the host name.
140
141               Note: This function does not handle IPv6 scope identifiers,
142               and should be used with care.
143               And, this function was deprecated in RFC3493.
144               The getaddrinfo function should be used instead.
145
146       gai_strerror ERROR_NUMBER
147               This function returns a string corresponding to the error number
148               passed in as an argument.
149
150       in6addr_any
151               This function returns the 16-octet wildcard address.
152
153       in6addr_loopback
154               This function returns the 16-octet loopback address.
155
156
157
158perl v5.34.0                      2022-01-21                        Socket6(3)
Impressum