1IO::Socket::INET6(3) User Contributed Perl Documentation IO::Socket::INET6(3)
2
3
4
6 IO::Socket::INET6 - Object interface for AF_INET|AF_INET6 domain
7 sockets
8
10 use IO::Socket::INET6;
11
13 "IO::Socket::INET6" provides an object interface to creating and using
14 sockets in either AF_INET or AF_INET6 domains. It is built upon the
15 IO::Socket interface and inherits all the methods defined by
16 IO::Socket.
17
19 new ( [ARGS] )
20 Creates an "IO::Socket::INET6" object, which is a reference to a
21 newly created symbol (see the "Symbol" package). "new" optionally
22 takes arguments, these arguments are in key-value pairs.
23
24 In addition to the key-value pairs accepted by IO::Socket,
25 "IO::Socket::INET6" provides.
26
27 Domain Address family AF_INET | AF_INET6 | AF_UNSPEC (default)
28 PeerAddr Remote host address <hostname>[:<port>]
29 PeerHost Synonym for PeerAddr
30 PeerPort Remote port or service <service>[(<no>)] | <no>
31 PeerFlow Remote flow information
32 PeerScope Remote address scope
33 LocalAddr Local host bind address hostname[:port]
34 LocalHost Synonym for LocalAddr
35 LocalPort Local host bind port <service>[(<no>)] | <no>
36 LocalFlow Local host flow information
37 LocalScope Local host address scope
38 Proto Protocol name (or number) "tcp" | "udp" | ...
39 Type Socket type SOCK_STREAM | SOCK_DGRAM | ...
40 Listen Queue size for listen
41 ReuseAddr Set SO_REUSEADDR before binding
42 Reuse Set SO_REUSEADDR before binding (deprecated, prefer ReuseAddr)
43 ReusePort Set SO_REUSEPORT before binding
44 Broadcast Set SO_BROADCAST before binding
45 Timeout Timeout value for various operations
46 MultiHomed Try all adresses for multi-homed hosts
47 Blocking Determine if connection will be blocking mode
48
49 If "Listen" is defined then a listen socket is created, else if the
50 socket type, which is derived from the protocol, is SOCK_STREAM
51 then connect() is called.
52
53 Although it is not illegal, the use of "MultiHomed" on a socket
54 which is in non-blocking mode is of little use. This is because the
55 first connect will never fail with a timeout as the connect call
56 will not block.
57
58 The "PeerAddr" can be a hostname, the IPv6-address on the
59 "2001:800:40:2a05::10" form , or the IPv4-address on the
60 "213.34.234.245" form. The "PeerPort" can be a number or a
61 symbolic service name. The service name might be followed by a
62 number in parenthesis which is used if the service is not known by
63 the system. The "PeerPort" specification can also be embedded in
64 the "PeerAddr" by preceding it with a ":", and closing the IPv6
65 address on bracktes "[]" if necessary:
66 "124.678.12.34:23","[2a05:345f::10]:23","any.server.com:23".
67
68 If "Domain" is not given, AF_UNSPEC is assumed, that is, both
69 AF_INET and AF_INET6 will be both considered when resolving DNS
70 names. AF_INET6 is prioritary. If you guess you are in trouble not
71 reaching the peer,(the service is not available via AF_INET6 but
72 AF_INET) you can either try Multihomed (try any address/family
73 until reach) or concrete your address "family" (AF_INET, AF_INET6).
74
75 If "Proto" is not given and you specify a symbolic "PeerPort" port,
76 then the constructor will try to derive "Proto" from the service
77 name. As a last resort "Proto" "tcp" is assumed. The "Type"
78 parameter will be deduced from "Proto" if not specified.
79
80 If the constructor is only passed a single argument, it is assumed
81 to be a "PeerAddr" specification.
82
83 If "Blocking" is set to 0, the connection will be in nonblocking
84 mode. If not specified it defaults to 1 (blocking mode).
85
86 Examples:
87
88 $sock = IO::Socket::INET6->new(PeerAddr => 'www.perl.org',
89 PeerPort => 'http(80)',
90 Proto => 'tcp');
91
92 Suppose either you have no IPv6 connectivity or www.perl.org has no
93 http service on IPv6. Then,
94
95 (Trying all address/families until reach)
96
97 $sock = IO::Socket::INET6->new(PeerAddr => 'www.perl.org',
98 PeerPort => 'http(80)',
99 Multihomed => 1 ,
100 Proto => 'tcp');
101
102 (Concrete to IPv4 protocol)
103
104 $sock = IO::Socket::INET6->new(PeerAddr => 'www.perl.org',
105 PeerPort => 'http(80)',
106 Domain => AF_INET ,
107 Proto => 'tcp');
108
109
110 $sock = IO::Socket::INET6->new(PeerAddr => 'localhost:smtp(25)');
111
112 $sock = IO::Socket::INET6->new(Listen => 5,
113 LocalAddr => 'localhost',
114 LocalPort => 9000,
115 Proto => 'tcp');
116
117 $sock = IO::Socket::INET6->new('[::1]:25');
118
119 $sock = IO::Socket::INET6->new(PeerPort => 9999,
120 PeerAddr => Socket6::inet_ntop(AF_INET6,in6addr_broadcast),
121 Proto => udp,
122 LocalAddr => 'localhost',
123 Broadcast => 1 )
124 or die "Can't bind : $@\n";
125
126 NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
127
128 As of VERSION 1.18 all IO::Socket objects have autoflush turned on
129 by default. This was not the case with earlier releases.
130
131 NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
132
133 METHODS
134 accept ()
135 See IO::Socket::INET.
136
137 bind ()
138 See IO::Socket::INET.
139
140 configure ()
141 This function exists in this module, but I (= Shlomi Fish) don't
142 know what it does, or understand it. It's also not tested anywhere.
143 I'll be happy to be enlightened.
144
145 connect ()
146 See IO::Socket::INET.
147
148 sockaddr ()
149 Return the address part of the sockaddr structure for the socket
150
151 sockdomain()
152 Returns the domain of the socket - AF_INET or AF_INET6 or whatever.
153
154 sockport ()
155 Return the port number that the socket is using on the local host
156
157 sockhost ()
158 Return the address part of the sockaddr structure for the socket in
159 a text form ("2001:800:40:2a05::10" or "245.245.13.27")
160
161 sockflow ()
162 Return the flow information part of the sockaddr structure for the
163 socket
164
165 sockscope ()
166 Return the scope identification part of the sockaddr structure for
167 the socket
168
169 peeraddr ()
170 Return the address part of the sockaddr structure for the socket on
171 the peer host
172
173 peerport ()
174 Return the port number for the socket on the peer host.
175
176 peerhost ()
177 Return the address part of the sockaddr structure for the socket on
178 the peer host in a text form ("2001:800:40:2a05::10" or
179 "245.245.13.27")
180
181 peerflow ()
182 Return the flow information part of the sockaddr structure for the
183 socket on the peer host
184
185 peerscope ()
186 Return the scope identification part of the sockaddr structure for
187 the socket on the peer host
188
190 The Subversion repository for this module carrying complete version
191 history and other information is:
192
193 <http://svn.berlios.de/svnroot/repos/web-cpan/IO-Socket-INET6/>
194
196 Socket,Socket6, IO::Socket
197
199 This program is based on IO::Socket::INET by Graham Barr
200 <gbarr@pobox.com> and currently maintained by the Perl Porters.
201
202 Modified by Rafael Martinez Torres <rafael.martinez@novagnet.com> and
203 Euro6IX project.
204
205 Modified further by Shlomi Fish <shlomif@iglu.org.il>, while
206 disclaiming all copyrights.
207
209 Copyright (c) 2003- Rafael Martinez Torres
210 <rafael.martinez@novagnet.com>.
211
212 Copyright (c) 2003- Euro6IX project.
213
214 Copyright (c) 1996-8 Graham Barr <gbarr@pobox.com>.
215
216 All rights reserved.
217
218 This program is free software; you can redistribute it and/or modify it
219 under the same terms as Perl itself.
220
221
222
223perl v5.16.3 2011-11-28 IO::Socket::INET6(3)