Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / IO / Socket / INET.html
blobbb5b1d5e0cb02ba05016360cd97cdf7c25a38ae6
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>IO::Socket::INET - Object interface for AF_INET domain sockets</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;IO::Socket::INET - Object interface for AF_INET domain sockets</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <li><a href="#constructor">CONSTRUCTOR</a></li>
26 <ul>
28 <li><a href="#methods">METHODS</a></li>
29 </ul>
31 <li><a href="#see_also">SEE ALSO</a></li>
32 <li><a href="#author">AUTHOR</a></li>
33 <li><a href="#copyright">COPYRIGHT</a></li>
34 </ul>
35 <!-- INDEX END -->
37 <hr />
38 <p>
39 </p>
40 <h1><a name="name">NAME</a></h1>
41 <p>IO::Socket::INET - Object interface for AF_INET domain sockets</p>
42 <p>
43 </p>
44 <hr />
45 <h1><a name="synopsis">SYNOPSIS</a></h1>
46 <pre>
47 use IO::Socket::INET;</pre>
48 <p>
49 </p>
50 <hr />
51 <h1><a name="description">DESCRIPTION</a></h1>
52 <p><code>IO::Socket::INET</code> provides an object interface to creating and using sockets
53 in the AF_INET domain. It is built upon the <a href="file://C|\msysgit\mingw\html/lib/IO/Socket.html">the IO::Socket manpage</a> interface and
54 inherits all the methods defined by <a href="file://C|\msysgit\mingw\html/lib/IO/Socket.html">the IO::Socket manpage</a>.</p>
55 <p>
56 </p>
57 <hr />
58 <h1><a name="constructor">CONSTRUCTOR</a></h1>
59 <dl>
60 <dt><strong><a name="item_new">new ( [ARGS] )</a></strong>
62 <dd>
63 <p>Creates an <code>IO::Socket::INET</code> object, which is a reference to a
64 newly created symbol (see the <code>Symbol</code> package). <a href="#item_new"><code>new</code></a>
65 optionally takes arguments, these arguments are in key-value pairs.</p>
66 </dd>
67 <dd>
68 <p>In addition to the key-value pairs accepted by <a href="file://C|\msysgit\mingw\html/lib/IO/Socket.html">the IO::Socket manpage</a>,
69 <code>IO::Socket::INET</code> provides.</p>
70 </dd>
71 <dd>
72 <pre>
73 PeerAddr Remote host address &lt;hostname&gt;[:&lt;port&gt;]
74 PeerHost Synonym for PeerAddr
75 PeerPort Remote port or service &lt;service&gt;[(&lt;no&gt;)] | &lt;no&gt;
76 LocalAddr Local host bind address hostname[:port]
77 LocalHost Synonym for LocalAddr
78 LocalPort Local host bind port &lt;service&gt;[(&lt;no&gt;)] | &lt;no&gt;
79 Proto Protocol name (or number) &quot;tcp&quot; | &quot;udp&quot; | ...
80 Type Socket type SOCK_STREAM | SOCK_DGRAM | ...
81 Listen Queue size for listen
82 ReuseAddr Set SO_REUSEADDR before binding
83 Reuse Set SO_REUSEADDR before binding (deprecated, prefer ReuseAddr)
84 ReusePort Set SO_REUSEPORT before binding
85 Broadcast Set SO_BROADCAST before binding
86 Timeout Timeout value for various operations
87 MultiHomed Try all addresses for multi-homed hosts
88 Blocking Determine if connection will be blocking mode</pre>
89 </dd>
90 <dd>
91 <p>If <code>Listen</code> is defined then a listen socket is created, else if the
92 socket type, which is derived from the protocol, is SOCK_STREAM then
93 <code>connect()</code> is called.</p>
94 </dd>
95 <dd>
96 <p>Although it is not illegal, the use of <code>MultiHomed</code> on a socket
97 which is in non-blocking mode is of little use. This is because the
98 first connect will never fail with a timeout as the connect call
99 will not block.</p>
100 </dd>
101 <dd>
102 <p>The <code>PeerAddr</code> can be a hostname or the IP-address on the
103 ``xx.xx.xx.xx'' form. The <code>PeerPort</code> can be a number or a symbolic
104 service name. The service name might be followed by a number in
105 parenthesis which is used if the service is not known by the system.
106 The <code>PeerPort</code> specification can also be embedded in the <code>PeerAddr</code>
107 by preceding it with a ``:''.</p>
108 </dd>
109 <dd>
110 <p>If <code>Proto</code> is not given and you specify a symbolic <code>PeerPort</code> port,
111 then the constructor will try to derive <code>Proto</code> from the service
112 name. As a last resort <code>Proto</code> ``tcp'' is assumed. The <code>Type</code>
113 parameter will be deduced from <code>Proto</code> if not specified.</p>
114 </dd>
115 <dd>
116 <p>If the constructor is only passed a single argument, it is assumed to
117 be a <code>PeerAddr</code> specification.</p>
118 </dd>
119 <dd>
120 <p>If <code>Blocking</code> is set to 0, the connection will be in nonblocking mode.
121 If not specified it defaults to 1 (blocking mode).</p>
122 </dd>
123 <dd>
124 <p>Examples:</p>
125 </dd>
126 <dd>
127 <pre>
128 $sock = IO::Socket::INET-&gt;new(PeerAddr =&gt; 'www.perl.org',
129 PeerPort =&gt; 'http(80)',
130 Proto =&gt; 'tcp');</pre>
131 </dd>
132 <dd>
133 <pre>
134 $sock = IO::Socket::INET-&gt;new(PeerAddr =&gt; 'localhost:smtp(25)');</pre>
135 </dd>
136 <dd>
137 <pre>
138 $sock = IO::Socket::INET-&gt;new(Listen =&gt; 5,
139 LocalAddr =&gt; 'localhost',
140 LocalPort =&gt; 9000,
141 Proto =&gt; 'tcp');</pre>
142 </dd>
143 <dd>
144 <pre>
145 $sock = IO::Socket::INET-&gt;new('127.0.0.1:25');</pre>
146 </dd>
147 <dd>
148 <pre>
149 $sock = IO::Socket::INET-&gt;new(PeerPort =&gt; 9999,
150 PeerAddr =&gt; inet_ntoa(INADDR_BROADCAST),
151 Proto =&gt; udp,
152 LocalAddr =&gt; 'localhost',
153 Broadcast =&gt; 1 )
154 or die &quot;Can't bind : $@\n&quot;;</pre>
155 </dd>
156 <dd>
157 <pre>
158 NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE</pre>
159 </dd>
160 <dd>
161 <p>As of VERSION 1.18 all IO::Socket objects have autoflush turned on
162 by default. This was not the case with earlier releases.</p>
163 </dd>
164 <dd>
165 <pre>
166 NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE</pre>
167 </dd>
168 </li>
169 </dl>
171 </p>
172 <h2><a name="methods">METHODS</a></h2>
173 <dl>
174 <dt><strong><a name="item_sockaddr">sockaddr ()</a></strong>
176 <dd>
177 <p>Return the address part of the sockaddr structure for the socket</p>
178 </dd>
179 </li>
180 <dt><strong><a name="item_sockport">sockport ()</a></strong>
182 <dd>
183 <p>Return the port number that the socket is using on the local host</p>
184 </dd>
185 </li>
186 <dt><strong><a name="item_sockhost">sockhost ()</a></strong>
188 <dd>
189 <p>Return the address part of the sockaddr structure for the socket in a
190 text form xx.xx.xx.xx</p>
191 </dd>
192 </li>
193 <dt><strong><a name="item_peeraddr">peeraddr ()</a></strong>
195 <dd>
196 <p>Return the address part of the sockaddr structure for the socket on
197 the peer host</p>
198 </dd>
199 </li>
200 <dt><strong><a name="item_peerport">peerport ()</a></strong>
202 <dd>
203 <p>Return the port number for the socket on the peer host.</p>
204 </dd>
205 </li>
206 <dt><strong><a name="item_peerhost">peerhost ()</a></strong>
208 <dd>
209 <p>Return the address part of the sockaddr structure for the socket on the
210 peer host in a text form xx.xx.xx.xx</p>
211 </dd>
212 </li>
213 </dl>
215 </p>
216 <hr />
217 <h1><a name="see_also">SEE ALSO</a></h1>
218 <p><a href="file://C|\msysgit\mingw\html/lib/Socket.html">the Socket manpage</a>, <a href="file://C|\msysgit\mingw\html/lib/IO/Socket.html">the IO::Socket manpage</a></p>
220 </p>
221 <hr />
222 <h1><a name="author">AUTHOR</a></h1>
223 <p>Graham Barr. Currently maintained by the Perl Porters. Please report all
224 bugs to &lt;<a href="mailto:perl5-porters@perl.org">perl5-porters@perl.org</a>&gt;.</p>
226 </p>
227 <hr />
228 <h1><a name="copyright">COPYRIGHT</a></h1>
229 <p>Copyright (c) 1996-8 Graham Barr &lt;<a href="mailto:gbarr@pobox.com">gbarr@pobox.com</a>&gt;. All rights reserved.
230 This program is free software; you can redistribute it and/or
231 modify it under the same terms as Perl itself.</p>
232 <table border="0" width="100%" cellspacing="0" cellpadding="3">
233 <tr><td class="block" style="background-color: #cccccc" valign="middle">
234 <big><strong><span class="block">&nbsp;IO::Socket::INET - Object interface for AF_INET domain sockets</span></strong></big>
235 </td></tr>
236 </table>
238 </body>
240 </html>