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       getaddrinfo NODENAME, SERVICENAME, [FAMILY, SOCKTYPE, PROTOCOL, FLAGS]
85               This function converts node names to addresses and service names
86               to port numbers.
87               If the NODENAME argument is not a false value,
88               then a nodename to address lookup is performed;
89               otherwise a service name to port number lookup is performed.
90               At least one of NODENAME and SERVICENAME must have a true value.
91
92               If the lookup is successful, a list consisting of multiples of
93               five elements is returned.
94               Each group of five elements consists of the address family,
95               socket type, protocol, 16-octet IP address, and the canonical
96               name (undef if the node name passed is already the canonical name).
97
98               The arguments FAMILY, SOCKTYPE, PROTOCOL, and FLAGS are all optional.
99
100               This function will croak if it determines it has not been
101               passed an IPv6 structure.
102
103               If the lookup is unsuccessful, the function returns a single scalar.
104               This will contain the string version of that error in string context,
105               and the numeric value in numeric context.
106
107       getnameinfo NAME, [FLAGS]
108               This function takes a socket address structure. If successful, it returns
109               two strings containing the node name and service name.
110
111               The optional FLAGS argument controls what kind of lookup is performed.
112
113               If the lookup is unsuccessful, the function returns a single scalar.
114               This will contain the string version of that error in string context,
115               and the numeric value in numeric context.
116
117       getipnodebyname HOST, [FAMILY, FLAGS]
118               This function takes either a node name or an IP address string
119               and performs a lookup on that name (or conversion of the string).
120               It returns a list of five elements: the canonical host name,
121               the address family, the length in octets of the IP addresses
122               returned, a reference to a list of IP address structures, and
123               a reference to a list of aliases for the host name.
124
125               The arguments FAMILY and FLAGS are optional.
126               Note: This function does not handle IPv6 scope identifiers,
127               and should be used with care.
128               And, this function was deprecated in RFC3493.
129               The getnameinfo function should be used instead.
130
131       getipnodebyaddr FAMILY, ADDRESS
132               This function takes an IP address family and an IP address structure
133               and performs a reverse lookup on that address.
134               It returns a list of five elements: the canonical host name,
135               the address family, the length in octets of the IP addresses
136               returned, a reference to a list of IP address structures, and
137               a reference to a list of aliases for the host name.
138
139               Note: This function does not handle IPv6 scope identifiers,
140               and should be used with care.
141               And, this function was deprecated in RFC3493.
142               The getaddrinfo function should be used instead.
143
144       gai_strerror ERROR_NUMBER
145               This function returns a string corresponding to the error number
146               passed in as an argument.
147
148       in6addr_any
149               This function returns the 16-octet wildcard address.
150
151       in6addr_loopback
152               This function returns the 16-octet loopback address.
153
154
155
156perl v5.32.0                      2020-07-28                        Socket6(3)
Impressum