aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/reference.html2
-rw-r--r--doc/tcp.html193
-rw-r--r--doc/udp.html159
3 files changed, 208 insertions, 146 deletions
diff --git a/doc/reference.html b/doc/reference.html
index e9bb5eb..6067ba6 100644
--- a/doc/reference.html
+++ b/doc/reference.html
@@ -160,9 +160,11 @@ Support, Manual">
160<a href="socket.html#setsize">_SETSIZE</a>, 160<a href="socket.html#setsize">_SETSIZE</a>,
161<a href="socket.html#source">source</a>, 161<a href="socket.html#source">source</a>,
162<a href="tcp.html#socket.tcp">tcp</a>, 162<a href="tcp.html#socket.tcp">tcp</a>,
163<a href="tcp.html#socket.tcp4">tcp4</a>,
163<a href="tcp.html#socket.tcp6">tcp6</a>, 164<a href="tcp.html#socket.tcp6">tcp6</a>,
164<a href="socket.html#try">try</a>, 165<a href="socket.html#try">try</a>,
165<a href="udp.html#socket.udp">udp</a>, 166<a href="udp.html#socket.udp">udp</a>,
167<a href="udp.html#socket.udp4">udp4</a>,
166<a href="udp.html#socket.udp6">udp6</a>, 168<a href="udp.html#socket.udp6">udp6</a>,
167<a href="socket.html#version">_VERSION</a>. 169<a href="socket.html#version">_VERSION</a>.
168</blockquote> 170</blockquote>
diff --git a/doc/tcp.html b/doc/tcp.html
index 4226d78..6fc9900 100644
--- a/doc/tcp.html
+++ b/doc/tcp.html
@@ -1,10 +1,10 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd"> 2 "http://www.w3.org/TR/html4/strict.dtd">
3<html> 3<html>
4 4
5<head> 5<head>
6<meta name="description" content="LuaSocket: The TCP/IP support"> 6<meta name="description" content="LuaSocket: The TCP/IP support">
7<meta name="keywords" content="Lua, LuaSocket, Socket, TCP, Library, Network, Support"> 7<meta name="keywords" content="Lua, LuaSocket, Socket, TCP, Library, Network, Support">
8<title>LuaSocket: TCP/IP support</title> 8<title>LuaSocket: TCP/IP support</title>
9<link rel="stylesheet" href="reference.css" type="text/css"> 9<link rel="stylesheet" href="reference.css" type="text/css">
10</head> 10</head>
@@ -28,7 +28,7 @@
28<a href="index.html#download">download</a> &middot; 28<a href="index.html#download">download</a> &middot;
29<a href="installation.html">installation</a> &middot; 29<a href="installation.html">installation</a> &middot;
30<a href="introduction.html">introduction</a> &middot; 30<a href="introduction.html">introduction</a> &middot;
31<a href="reference.html">reference</a> 31<a href="reference.html">reference</a>
32</p> 32</p>
33</center> 33</center>
34<hr> 34<hr>
@@ -36,21 +36,48 @@
36 36
37<!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 37<!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
38 38
39<h2 id="tcp">TCP</h2> 39<h2 id="tcp">TCP</h2>
40 40
41<!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 41<!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
42 42
43<p class=name id="socket.tcp"> 43<p class=name id="socket.tcp">
44socket.<b>tcp()</b> 44socket.<b>tcp()</b>
45</p> 45</p>
46 46
47<p class=description> 47<p class=description>
48Creates and returns an TCP master object. A master object can
49be transformed into a server object with the method
50<a href=#listen><tt>listen</tt></a> (after a call to <a
51href=#bind><tt>bind</tt></a>) or into a client object with
52the method <a href=#connect><tt>connect</tt></a>. The only other
53method supported by a master object is the
54<a href=#close><tt>close</tt></a> method.</p>
55
56<p class=return>
57In case of success, a new master object is returned. In case of error,
58<b><tt>nil</tt></b> is returned, followed by an error message.
59</p>
60
61<p class=note>
62Note: The choice between IPv4 and IPv6 happens during a call to
63<a href=#bind><tt>bind</tt></a> or <a
64href=#bind><tt>connect</tt></a>, depending on the address
65family obtained from the resolver.
66</p>
67
68<!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
69
70<p class=name id="socket.tcp4">
71socket.<b>tcp4()</b>
72</p>
73
74<p class=description>
48Creates and returns an IPv4 TCP master object. A master object can 75Creates and returns an IPv4 TCP master object. A master object can
49be transformed into a server object with the method 76be transformed into a server object with the method
50<a href=#listen><tt>listen</tt></a> (after a call to <a 77<a href=#listen><tt>listen</tt></a> (after a call to <a
51href=#bind><tt>bind</tt></a>) or into a client object with 78href=#bind><tt>bind</tt></a>) or into a client object with
52the method <a href=#connect><tt>connect</tt></a>. The only other 79the method <a href=#connect><tt>connect</tt></a>. The only other
53method supported by a master object is the 80method supported by a master object is the
54<a href=#close><tt>close</tt></a> method.</p> 81<a href=#close><tt>close</tt></a> method.</p>
55 82
56<p class=return> 83<p class=return>
@@ -60,17 +87,17 @@ In case of success, a new master object is returned. In case of error,
60 87
61<!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 88<!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
62 89
63<p class=name id="socket.tcp6"> 90<p class=name id="socket.tcp6">
64socket.<b>tcp6()</b> 91socket.<b>tcp6()</b>
65</p> 92</p>
66 93
67<p class=description> 94<p class=description>
68Creates and returns an IPv6 TCP master object. A master object can 95Creates and returns an IPv6 TCP master object. A master object can
69be transformed into a server object with the method 96be transformed into a server object with the method
70<a href=#listen><tt>listen</tt></a> (after a call to <a 97<a href=#listen><tt>listen</tt></a> (after a call to <a
71href=#bind><tt>bind</tt></a>) or into a client object with 98href=#bind><tt>bind</tt></a>) or into a client object with
72the method <a href=#connect><tt>connect</tt></a>. The only other 99the method <a href=#connect><tt>connect</tt></a>. The only other
73method supported by a master object is the 100method supported by a master object is the
74<a href=#close><tt>close</tt></a> method.</p> 101<a href=#close><tt>close</tt></a> method.</p>
75 102
76<p class=return> 103<p class=return>
@@ -85,7 +112,7 @@ Note: The TCP object returned will have the option
85 112
86<!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 113<!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
87 114
88<p class=name id="accept"> 115<p class=name id="accept">
89server:<b>accept()</b> 116server:<b>accept()</b>
90</p> 117</p>
91 118
@@ -95,9 +122,9 @@ object and returns a client object representing that connection.
95</p> 122</p>
96 123
97<p class=return> 124<p class=return>
98If a connection is successfully initiated, a client object is returned. 125If a connection is successfully initiated, a client object is returned.
99If a timeout condition is met, the method returns <b><tt>nil</tt></b> 126If a timeout condition is met, the method returns <b><tt>nil</tt></b>
100followed by the error string '<tt>timeout</tt>'. Other errors are 127followed by the error string '<tt>timeout</tt>'. Other errors are
101reported by <b><tt>nil</tt></b> followed by a message describing the error. 128reported by <b><tt>nil</tt></b> followed by a message describing the error.
102</p> 129</p>
103 130
@@ -107,28 +134,28 @@ with a server object in
107the <tt>recvt</tt> parameter before a call to <tt>accept</tt> does 134the <tt>recvt</tt> parameter before a call to <tt>accept</tt> does
108<em>not</em> guarantee <tt>accept</tt> will return immediately. Use the <a 135<em>not</em> guarantee <tt>accept</tt> will return immediately. Use the <a
109href=#settimeout><tt>settimeout</tt></a> method or <tt>accept</tt> 136href=#settimeout><tt>settimeout</tt></a> method or <tt>accept</tt>
110might block until <em>another</em> client shows up. 137might block until <em>another</em> client shows up.
111</p> 138</p>
112 139
113<!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 140<!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
114 141
115<p class=name id="bind"> 142<p class=name id="bind">
116master:<b>bind(</b>address, port<b>)</b> 143master:<b>bind(</b>address, port<b>)</b>
117</p> 144</p>
118 145
119<p class=description> 146<p class=description>
120Binds a master object to <tt>address</tt> and <tt>port</tt> on the 147Binds a master object to <tt>address</tt> and <tt>port</tt> on the
121local host. 148local host.
122 149
123<p class=parameters> 150<p class=parameters>
124<tt>Address</tt> can be an IP address or a host name. 151<tt>Address</tt> can be an IP address or a host name.
125<tt>Port</tt> must be an integer number in the range [0..64K). 152<tt>Port</tt> must be an integer number in the range [0..64K).
126If <tt>address</tt> 153If <tt>address</tt>
127is '<tt>*</tt>', the system binds to all local interfaces 154is '<tt>*</tt>', the system binds to all local interfaces
128using the <tt>INADDR_ANY</tt> constant or 155using the <tt>INADDR_ANY</tt> constant or
129<tt>IN6ADDR_ANY_INIT</tt>, according to the family. 156<tt>IN6ADDR_ANY_INIT</tt>, according to the family.
130If <tt>port</tt> is 0, the system automatically 157If <tt>port</tt> is 0, the system automatically
131chooses an ephemeral port. 158chooses an ephemeral port.
132</p> 159</p>
133 160
134<p class=return> 161<p class=return>
@@ -137,13 +164,13 @@ method returns <b><tt>nil</tt></b> followed by an error message.
137</p> 164</p>
138 165
139<p class=note> 166<p class=note>
140Note: The function <a href=socket.html#bind><tt>socket.bind</tt></a> 167Note: The function <a href=socket.html#bind><tt>socket.bind</tt></a>
141is available and is a shortcut for the creation of server sockets. 168is available and is a shortcut for the creation of server sockets.
142</p> 169</p>
143 170
144<!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 171<!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
145 172
146<p class=name id="close"> 173<p class=name id="close">
147master:<b>close()</b><br> 174master:<b>close()</b><br>
148client:<b>close()</b><br> 175client:<b>close()</b><br>
149server:<b>close()</b> 176server:<b>close()</b>
@@ -154,14 +181,14 @@ Closes a TCP object. The internal socket used by the object is closed
154and the local address to which the object was 181and the local address to which the object was
155bound is made available to other applications. No further operations 182bound is made available to other applications. No further operations
156(except for further calls to the <tt>close</tt> method) are allowed on 183(except for further calls to the <tt>close</tt> method) are allowed on
157a closed socket. 184a closed socket.
158</p> 185</p>
159 186
160<p class=note> 187<p class=note>
161Note: It is important to close all used sockets once they are not 188Note: It is important to close all used sockets once they are not
162needed, since, in many systems, each socket uses a file descriptor, 189needed, since, in many systems, each socket uses a file descriptor,
163which are limited system resources. Garbage-collected objects are 190which are limited system resources. Garbage-collected objects are
164automatically closed before destruction, though. 191automatically closed before destruction, though.
165</p> 192</p>
166 193
167<!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 194<!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -172,19 +199,19 @@ master:<b>connect(</b>address, port<b>)</b>
172 199
173<p class=description> 200<p class=description>
174Attempts to connect a master object to a remote host, transforming it into a 201Attempts to connect a master object to a remote host, transforming it into a
175client object. 202client object.
176Client objects support methods 203Client objects support methods
177<a href=#send><tt>send</tt></a>, 204<a href=#send><tt>send</tt></a>,
178<a href=#receive><tt>receive</tt></a>, 205<a href=#receive><tt>receive</tt></a>,
179<a href=#getsockname><tt>getsockname</tt></a>, 206<a href=#getsockname><tt>getsockname</tt></a>,
180<a href=#getpeername><tt>getpeername</tt></a>, 207<a href=#getpeername><tt>getpeername</tt></a>,
181<a href=#settimeout><tt>settimeout</tt></a>, 208<a href=#settimeout><tt>settimeout</tt></a>,
182and <a href=#close><tt>close</tt></a>. 209and <a href=#close><tt>close</tt></a>.
183</p> 210</p>
184 211
185<p class=parameters> 212<p class=parameters>
186<tt>Address</tt> can be an IP address or a host name. 213<tt>Address</tt> can be an IP address or a host name.
187<tt>Port</tt> must be an integer number in the range [1..64K). 214<tt>Port</tt> must be an integer number in the range [1..64K).
188</p> 215</p>
189 216
190<p class=return> 217<p class=return>
@@ -193,14 +220,14 @@ describing the error. In case of success, the method returns 1.
193</p> 220</p>
194 221
195<p class=note> 222<p class=note>
196Note: The function <a href=socket.html#connect><tt>socket.connect</tt></a> 223Note: The function <a href=socket.html#connect><tt>socket.connect</tt></a>
197is available and is a shortcut for the creation of client sockets. 224is available and is a shortcut for the creation of client sockets.
198</p> 225</p>
199 226
200<p class=note> 227<p class=note>
201Note: Starting with LuaSocket 2.0, 228Note: Starting with LuaSocket 2.0,
202the <a href=#settimeout><tt>settimeout</tt></a> 229the <a href=#settimeout><tt>settimeout</tt></a>
203method affects the behavior of <tt>connect</tt>, causing it to return 230method affects the behavior of <tt>connect</tt>, causing it to return
204with an error in case of a timeout. If that happens, you can still call <a 231with an error in case of a timeout. If that happens, you can still call <a
205href=socket.html#select><tt>socket.select</tt></a> with the socket in the 232href=socket.html#select><tt>socket.select</tt></a> with the socket in the
206<tt>sendt</tt> table. The socket will be writable when the connection is 233<tt>sendt</tt> table. The socket will be writable when the connection is
@@ -227,10 +254,10 @@ Returns information about the remote side of a connected client object.
227</p> 254</p>
228 255
229<p class=return> 256<p class=return>
230Returns a string with the IP address of the peer, the 257Returns a string with the IP address of the peer, the
231port number that peer is using for the connection, 258port number that peer is using for the connection,
232and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). 259and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
233In case of error, the method returns <b><tt>nil</tt></b>. 260In case of error, the method returns <b><tt>nil</tt></b>.
234</p> 261</p>
235 262
236<p class=note> 263<p class=note>
@@ -246,13 +273,13 @@ server:<b>getsockname()</b>
246</p> 273</p>
247 274
248<p class=description> 275<p class=description>
249Returns the local address information associated to the object. 276Returns the local address information associated to the object.
250</p> 277</p>
251 278
252<p class=return> 279<p class=return>
253The method returns a string with local IP address, a number with 280The method returns a string with local IP address, a number with
254the local port, 281the local port,
255and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). 282and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
256In case of error, the method returns <b><tt>nil</tt></b>. 283In case of error, the method returns <b><tt>nil</tt></b>.
257</p> 284</p>
258 285
@@ -266,32 +293,32 @@ server:<b>getstats()</b><br>
266 293
267<p class=description> 294<p class=description>
268Returns accounting information on the socket, useful for throttling 295Returns accounting information on the socket, useful for throttling
269of bandwidth. 296of bandwidth.
270</p> 297</p>
271 298
272<p class=return> 299<p class=return>
273The method returns the number of bytes received, the number of bytes sent, 300The method returns the number of bytes received, the number of bytes sent,
274and the age of the socket object in seconds. 301and the age of the socket object in seconds.
275</p> 302</p>
276 303
277<!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 304<!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
278 305
279<p class=name id="listen"> 306<p class=name id="listen">
280master:<b>listen(</b>backlog<b>)</b> 307master:<b>listen(</b>backlog<b>)</b>
281</p> 308</p>
282 309
283<p class=description> 310<p class=description>
284Specifies the socket is willing to receive connections, transforming the 311Specifies the socket is willing to receive connections, transforming the
285object into a server object. Server objects support the 312object into a server object. Server objects support the
286<a href=#accept><tt>accept</tt></a>, 313<a href=#accept><tt>accept</tt></a>,
287<a href=#getsockname><tt>getsockname</tt></a>, 314<a href=#getsockname><tt>getsockname</tt></a>,
288<a href=#setoption><tt>setoption</tt></a>, 315<a href=#setoption><tt>setoption</tt></a>,
289<a href=#settimeout><tt>settimeout</tt></a>, 316<a href=#settimeout><tt>settimeout</tt></a>,
290and <a href=#close><tt>close</tt></a> methods. 317and <a href=#close><tt>close</tt></a> methods.
291</p> 318</p>
292 319
293<p class=parameters> 320<p class=parameters>
294The parameter <tt>backlog</tt> specifies the number of client 321The parameter <tt>backlog</tt> specifies the number of client
295connections that can 322connections that can
296be queued waiting for service. If the queue is full and another client 323be queued waiting for service. If the queue is full and another client
297attempts connection, the connection is refused. 324attempts connection, the connection is refused.
@@ -310,11 +337,11 @@ client:<b>receive(</b>[pattern [, prefix]]<b>)</b>
310 337
311<p class=description> 338<p class=description>
312Reads data from a client object, according to the specified <em>read 339Reads data from a client object, according to the specified <em>read
313pattern</em>. Patterns follow the Lua file I/O format, and the difference in performance between all patterns is negligible. 340pattern</em>. Patterns follow the Lua file I/O format, and the difference in performance between all patterns is negligible.
314</p> 341</p>
315 342
316<p class=parameters> 343<p class=parameters>
317<tt>Pattern</tt> can be any of the following: 344<tt>Pattern</tt> can be any of the following:
318</p> 345</p>
319 346
320<ul> 347<ul>
@@ -325,7 +352,7 @@ terminated by a LF character (ASCII&nbsp;10), optionally preceded by a
325CR character (ASCII&nbsp;13). The CR and LF characters are not included in 352CR character (ASCII&nbsp;13). The CR and LF characters are not included in
326the returned line. In fact, <em>all</em> CR characters are 353the returned line. In fact, <em>all</em> CR characters are
327ignored by the pattern. This is the default pattern; 354ignored by the pattern. This is the default pattern;
328<li> <tt>number</tt>: causes the method to read a specified <tt>number</tt> 355<li> <tt>number</tt>: causes the method to read a specified <tt>number</tt>
329of bytes from the socket. 356of bytes from the socket.
330</ul> 357</ul>
331 358
@@ -347,10 +374,10 @@ closed before the transmission was completed or the string
347<p class=note> 374<p class=note>
348<b>Important note</b>: This function was changed <em>severely</em>. It used 375<b>Important note</b>: This function was changed <em>severely</em>. It used
349to support multiple patterns (but I have never seen this feature used) and 376to support multiple patterns (but I have never seen this feature used) and
350now it doesn't anymore. Partial results used to be returned in the same 377now it doesn't anymore. Partial results used to be returned in the same
351way as successful results. This last feature violated the idea that all 378way as successful results. This last feature violated the idea that all
352functions should return <tt><b>nil</b></tt> on error. Thus it was changed 379functions should return <tt><b>nil</b></tt> on error. Thus it was changed
353too. 380too.
354</p> 381</p>
355 382
356<!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 383<!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -366,7 +393,7 @@ Sends <tt>data</tt> through client object.
366<p class=parameters> 393<p class=parameters>
367<tt>Data</tt> is the string to be sent. The optional arguments 394<tt>Data</tt> is the string to be sent. The optional arguments
368<tt>i</tt> and <tt>j</tt> work exactly like the standard 395<tt>i</tt> and <tt>j</tt> work exactly like the standard
369<tt>string.sub</tt> Lua function to allow the selection of a 396<tt>string.sub</tt> Lua function to allow the selection of a
370substring to be sent. 397substring to be sent.
371</p> 398</p>
372 399
@@ -385,10 +412,10 @@ there was a timeout during the operation.
385</p> 412</p>
386 413
387<p class=note> 414<p class=note>
388Note: Output is <em>not</em> buffered. For small strings, 415Note: Output is <em>not</em> buffered. For small strings,
389it is always better to concatenate them in Lua 416it is always better to concatenate them in Lua
390(with the '<tt>..</tt>' operator) and send the result in one call 417(with the '<tt>..</tt>' operator) and send the result in one call
391instead of calling the method several times. 418instead of calling the method several times.
392</p> 419</p>
393 420
394<!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 421<!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -400,12 +427,12 @@ server:<b>setoption(</b>option [, value]<b>)</b>
400 427
401<p class=description> 428<p class=description>
402Sets options for the TCP object. Options are only needed by low-level or 429Sets options for the TCP object. Options are only needed by low-level or
403time-critical applications. You should only modify an option if you 430time-critical applications. You should only modify an option if you
404are sure you need it. 431are sure you need it.
405</p> 432</p>
406 433
407<p class=parameters> 434<p class=parameters>
408<tt>Option</tt> is a string with the option name, and <tt>value</tt> 435<tt>Option</tt> is a string with the option name, and <tt>value</tt>
409depends on the option being set: 436depends on the option being set:
410 437
411<ul> 438<ul>
@@ -413,7 +440,7 @@ depends on the option being set:
413<li> '<tt>keepalive</tt>': Setting this option to <tt>true</tt> enables 440<li> '<tt>keepalive</tt>': Setting this option to <tt>true</tt> enables
414the periodic transmission of messages on a connected socket. Should the 441the periodic transmission of messages on a connected socket. Should the
415connected party fail to respond to these messages, the connection is 442connected party fail to respond to these messages, the connection is
416considered broken and processes using the socket are notified; 443considered broken and processes using the socket are notified;
417 444
418<li> '<tt>linger</tt>': Controls the action taken when unsent data are 445<li> '<tt>linger</tt>': Controls the action taken when unsent data are
419queued on a socket and a close is performed. The value is a table with a 446queued on a socket and a close is performed. The value is a table with a
@@ -424,13 +451,13 @@ it is able to transmit the data or until '<tt>timeout</tt>' has passed. If
424'<tt>on</tt>' is <tt>false</tt> and a close is issued, the system will 451'<tt>on</tt>' is <tt>false</tt> and a close is issued, the system will
425process the close in a manner that allows the process to continue as 452process the close in a manner that allows the process to continue as
426quickly as possible. I do not advise you to set this to anything other than 453quickly as possible. I do not advise you to set this to anything other than
427zero; 454zero;
428 455
429<li> '<tt>reuseaddr</tt>': Setting this option indicates that the rules 456<li> '<tt>reuseaddr</tt>': Setting this option indicates that the rules
430used in validating addresses supplied in a call to 457used in validating addresses supplied in a call to
431<a href=#bind><tt>bind</tt></a> should allow reuse of local addresses; 458<a href=#bind><tt>bind</tt></a> should allow reuse of local addresses;
432 459
433<li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt> 460<li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt>
434disables the Nagle's algorithm for the connection; 461disables the Nagle's algorithm for the connection;
435 462
436<li> '<tt>ipv6-v6only</tt>': 463<li> '<tt>ipv6-v6only</tt>':
@@ -485,7 +512,7 @@ server:<b>setstats(</b>received, sent, age<b>)</b><br>
485 512
486<p class=description> 513<p class=description>
487Resets accounting information on the socket, useful for throttling 514Resets accounting information on the socket, useful for throttling
488of bandwidth. 515of bandwidth.
489</p> 516</p>
490 517
491<p class=parameters> 518<p class=parameters>
@@ -495,7 +522,7 @@ of bandwidth.
495</p> 522</p>
496 523
497<p class=return> 524<p class=return>
498The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise. 525The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise.
499</p> 526</p>
500 527
501<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 528<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -509,8 +536,8 @@ server:<b>settimeout(</b>value [, mode]<b>)</b>
509<p class=description> 536<p class=description>
510Changes the timeout values for the object. By default, 537Changes the timeout values for the object. By default,
511all I/O operations are blocking. That is, any call to the methods 538all I/O operations are blocking. That is, any call to the methods
512<a href=#send><tt>send</tt></a>, 539<a href=#send><tt>send</tt></a>,
513<a href=#receive><tt>receive</tt></a>, and 540<a href=#receive><tt>receive</tt></a>, and
514<a href=#accept><tt>accept</tt></a> 541<a href=#accept><tt>accept</tt></a>
515will block indefinitely, until the operation completes. The 542will block indefinitely, until the operation completes. The
516<tt>settimeout</tt> method defines a limit on the amount of time the 543<tt>settimeout</tt> method defines a limit on the amount of time the
@@ -521,7 +548,7 @@ time has elapsed, the affected methods give up and fail with an error code.
521<p class=parameters> 548<p class=parameters>
522The amount of time to wait is specified as the 549The amount of time to wait is specified as the
523<tt>value</tt> parameter, in seconds. There are two timeout modes and 550<tt>value</tt> parameter, in seconds. There are two timeout modes and
524both can be used together for fine tuning: 551both can be used together for fine tuning:
525</p> 552</p>
526 553
527<ul> 554<ul>
@@ -532,7 +559,7 @@ default mode;</li>
532 559
533<li> '<tt>t</tt>': <em>total</em> timeout. Specifies the upper limit on 560<li> '<tt>t</tt>': <em>total</em> timeout. Specifies the upper limit on
534the amount of time LuaSocket can block a Lua script before returning from 561the amount of time LuaSocket can block a Lua script before returning from
535a call.</li> 562a call.</li>
536</ul> 563</ul>
537 564
538<p class=parameters> 565<p class=parameters>
@@ -562,7 +589,7 @@ client:<b>shutdown(</b>mode<b>)</b><br>
562</p> 589</p>
563 590
564<p class=description> 591<p class=description>
565Shuts down part of a full-duplex connection. 592Shuts down part of a full-duplex connection.
566</p> 593</p>
567 594
568<p class=parameters> 595<p class=parameters>
@@ -608,7 +635,7 @@ server:<b>getfd()</b>
608</p> 635</p>
609 636
610<p class=description> 637<p class=description>
611Returns the underling socket descriptor or handle associated to the object. 638Returns the underling socket descriptor or handle associated to the object.
612</p> 639</p>
613 640
614<p class=return> 641<p class=return>
diff --git a/doc/udp.html b/doc/udp.html
index e5b0ad0..e313af4 100644
--- a/doc/udp.html
+++ b/doc/udp.html
@@ -4,7 +4,7 @@
4 4
5<head> 5<head>
6<meta name="description" content="LuaSocket: The UDP support"> 6<meta name="description" content="LuaSocket: The UDP support">
7<meta name="keywords" content="Lua, LuaSocket, Socket, UDP, Library, Network, Support"> 7<meta name="keywords" content="Lua, LuaSocket, Socket, UDP, Library, Network, Support">
8<title>LuaSocket: UDP support</title> 8<title>LuaSocket: UDP support</title>
9<link rel="stylesheet" href="reference.css" type="text/css"> 9<link rel="stylesheet" href="reference.css" type="text/css">
10</head> 10</head>
@@ -28,7 +28,7 @@
28<a href="index.html#download">download</a> &middot; 28<a href="index.html#download">download</a> &middot;
29<a href="installation.html">installation</a> &middot; 29<a href="installation.html">installation</a> &middot;
30<a href="introduction.html">introduction</a> &middot; 30<a href="introduction.html">introduction</a> &middot;
31<a href="reference.html">reference</a> 31<a href="reference.html">reference</a>
32</p> 32</p>
33</center> 33</center>
34<hr> 34<hr>
@@ -37,7 +37,7 @@
37 37
38<!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 38<!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
39 39
40<h2 id="udp">UDP</h2> 40<h2 id="udp">UDP</h2>
41 41
42<!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 42<!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
43 43
@@ -46,19 +46,56 @@ socket.<b>udp()</b>
46</p> 46</p>
47 47
48<p class="description"> 48<p class="description">
49Creates and returns an unconnected IPv4 UDP object. 49Creates and returns an unconnected UDP object.
50Unconnected objects support the 50Unconnected objects support the
51<a href="#sendto"><tt>sendto</tt></a>, 51<a href="#sendto"><tt>sendto</tt></a>,
52<a href="#receive"><tt>receive</tt></a>, 52<a href="#receive"><tt>receive</tt></a>,
53<a href="#receivefrom"><tt>receivefrom</tt></a>, 53<a href="#receivefrom"><tt>receivefrom</tt></a>,
54<a href="#getoption"><tt>getoption</tt></a>, 54<a href="#getoption"><tt>getoption</tt></a>,
55<a href="#getsockname"><tt>getsockname</tt></a>, 55<a href="#getsockname"><tt>getsockname</tt></a>,
56<a href="#setoption"><tt>setoption</tt></a>, 56<a href="#setoption"><tt>setoption</tt></a>,
57<a href="#settimeout"><tt>settimeout</tt></a>, 57<a href="#settimeout"><tt>settimeout</tt></a>,
58<a href="#setpeername"><tt>setpeername</tt></a>, 58<a href="#setpeername"><tt>setpeername</tt></a>,
59<a href="#setsockname"><tt>setsockname</tt></a>, and 59<a href="#setsockname"><tt>setsockname</tt></a>, and
60<a href="#close"><tt>close</tt></a>. 60<a href="#close"><tt>close</tt></a>.
61The <a href="#setpeername"><tt>setpeername</tt></a> 61The <a href="#setpeername"><tt>setpeername</tt></a>
62is used to connect the object.
63</p>
64
65<p class="return">
66In case of success, a new unconnected UDP object
67returned. In case of error, <b><tt>nil</tt></b> is returned, followed by
68an error message.
69</p>
70
71<p class=note>
72Note: The choice between IPv4 and IPv6 happens during a call to
73<a href=#sendto><tt>sendto</tt></a>, <a
74href=#setpeername><tt>setpeername</tt></a>, or <a
75href=#setsockname><tt>sockname</tt></a>, depending on the address
76family obtained from the resolver.
77</p>
78
79<!-- socket.udp4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
80
81<p class="name" id="socket.udp">
82socket.<b>udp4()</b>
83</p>
84
85<p class="description">
86Creates and returns an unconnected IPv4 UDP object.
87Unconnected objects support the
88<a href="#sendto"><tt>sendto</tt></a>,
89<a href="#receive"><tt>receive</tt></a>,
90<a href="#receivefrom"><tt>receivefrom</tt></a>,
91<a href="#getoption"><tt>getoption</tt></a>,
92<a href="#getsockname"><tt>getsockname</tt></a>,
93<a href="#setoption"><tt>setoption</tt></a>,
94<a href="#settimeout"><tt>settimeout</tt></a>,
95<a href="#setpeername"><tt>setpeername</tt></a>,
96<a href="#setsockname"><tt>setsockname</tt></a>, and
97<a href="#close"><tt>close</tt></a>.
98The <a href="#setpeername"><tt>setpeername</tt></a>
62is used to connect the object. 99is used to connect the object.
63</p> 100</p>
64 101
@@ -75,19 +112,19 @@ socket.<b>udp6()</b>
75</p> 112</p>
76 113
77<p class="description"> 114<p class="description">
78Creates and returns an unconnected IPv6 UDP object. 115Creates and returns an unconnected IPv6 UDP object.
79Unconnected objects support the 116Unconnected objects support the
80<a href="#sendto"><tt>sendto</tt></a>, 117<a href="#sendto"><tt>sendto</tt></a>,
81<a href="#receive"><tt>receive</tt></a>, 118<a href="#receive"><tt>receive</tt></a>,
82<a href="#receivefrom"><tt>receivefrom</tt></a>, 119<a href="#receivefrom"><tt>receivefrom</tt></a>,
83<a href="#getoption"><tt>getoption</tt></a>, 120<a href="#getoption"><tt>getoption</tt></a>,
84<a href="#getsockname"><tt>getsockname</tt></a>, 121<a href="#getsockname"><tt>getsockname</tt></a>,
85<a href="#setoption"><tt>setoption</tt></a>, 122<a href="#setoption"><tt>setoption</tt></a>,
86<a href="#settimeout"><tt>settimeout</tt></a>, 123<a href="#settimeout"><tt>settimeout</tt></a>,
87<a href="#setpeername"><tt>setpeername</tt></a>, 124<a href="#setpeername"><tt>setpeername</tt></a>,
88<a href="#setsockname"><tt>setsockname</tt></a>, and 125<a href="#setsockname"><tt>setsockname</tt></a>, and
89<a href="#close"><tt>close</tt></a>. 126<a href="#close"><tt>close</tt></a>.
90The <a href="#setpeername"><tt>setpeername</tt></a> 127The <a href="#setpeername"><tt>setpeername</tt></a>
91is used to connect the object. 128is used to connect the object.
92</p> 129</p>
93 130
@@ -102,10 +139,6 @@ Note: The TCP object returned will have the option
102"<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>. 139"<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>.
103</p> 140</p>
104 141
105
106
107<!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
108
109<!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 142<!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
110 143
111<p class="name" id="close"> 144<p class="name" id="close">
@@ -142,10 +175,10 @@ associated with a connected UDP object.
142 175
143 176
144<p class=return> 177<p class=return>
145Returns a string with the IP address of the peer, the 178Returns a string with the IP address of the peer, the
146port number that peer is using for the connection, 179port number that peer is using for the connection,
147and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). 180and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
148In case of error, the method returns <b><tt>nil</tt></b>. 181In case of error, the method returns <b><tt>nil</tt></b>.
149</p> 182</p>
150 183
151<p class="note"> 184<p class="note">
@@ -165,9 +198,9 @@ Returns the local address information associated to the object.
165 198
166 199
167<p class=return> 200<p class=return>
168The method returns a string with local IP address, a number with 201The method returns a string with local IP address, a number with
169the local port, 202the local port,
170and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). 203and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
171In case of error, the method returns <b><tt>nil</tt></b>. 204In case of error, the method returns <b><tt>nil</tt></b>.
172</p> 205</p>
173 206
@@ -217,7 +250,7 @@ unconnected:<b>receivefrom(</b>[size]<b>)</b>
217</p> 250</p>
218 251
219<p class="description"> 252<p class="description">
220Works exactly as the <a href="#receive"><tt>receive</tt></a> 253Works exactly as the <a href="#receive"><tt>receive</tt></a>
221method, except it returns the IP 254method, except it returns the IP
222address and port as extra return values (and is therefore slightly less 255address and port as extra return values (and is therefore slightly less
223efficient). 256efficient).
@@ -236,7 +269,7 @@ See <a href=#setoption><tt>setoption</tt></a> for
236description of the option names and values. 269description of the option names and values.
237</p> 270</p>
238 271
239<p class="parameters"><tt>Option</tt> is a string with the option name. 272<p class="parameters"><tt>Option</tt> is a string with the option name.
240<ul> 273<ul>
241<li> '<tt>dontroute</tt>' 274<li> '<tt>dontroute</tt>'
242<li> '<tt>broadcast</tt>' 275<li> '<tt>broadcast</tt>'
@@ -246,9 +279,9 @@ description of the option names and values.
246<li> '<tt>ipv6-v6only</tt>' 279<li> '<tt>ipv6-v6only</tt>'
247<li> '<tt>ip-multicast-if</tt>' 280<li> '<tt>ip-multicast-if</tt>'
248<li> '<tt>ip-multicast-ttl</tt>' 281<li> '<tt>ip-multicast-ttl</tt>'
249<li> '<tt>ip-add-membership</tt>' 282<li> '<tt>ip-add-membership</tt>'
250<li> '<tt>ip-drop-membership</tt>' 283<li> '<tt>ip-drop-membership</tt>'
251</ul> 284</ul>
252</p> 285</p>
253 286
254<p class=return> 287<p class=return>
@@ -268,7 +301,7 @@ Sends a datagram to the UDP peer of a connected object.
268</p> 301</p>
269 302
270<p class="parameters"> 303<p class="parameters">
271<tt>Datagram</tt> is a string with the datagram contents. 304<tt>Datagram</tt> is a string with the datagram contents.
272The maximum datagram size for UDP is 64K minus IP layer overhead. 305The maximum datagram size for UDP is 64K minus IP layer overhead.
273However datagrams larger than the link layer packet size will be 306However datagrams larger than the link layer packet size will be
274fragmented, which may deteriorate performance and/or reliability. 307fragmented, which may deteriorate performance and/or reliability.
@@ -298,11 +331,11 @@ Sends a datagram to the specified IP address and port number.
298 331
299<p class="parameters"> 332<p class="parameters">
300<tt>Datagram</tt> is a string with the 333<tt>Datagram</tt> is a string with the
301datagram contents. 334datagram contents.
302The maximum datagram size for UDP is 64K minus IP layer overhead. 335The maximum datagram size for UDP is 64K minus IP layer overhead.
303However datagrams larger than the link layer packet size will be 336However datagrams larger than the link layer packet size will be
304fragmented, which may deteriorate performance and/or reliability. 337fragmented, which may deteriorate performance and/or reliability.
305<tt>Ip</tt> is the IP address of the recipient. 338<tt>Ip</tt> is the IP address of the recipient.
306Host names are <em>not</em> allowed for performance reasons. 339Host names are <em>not</em> allowed for performance reasons.
307 340
308<tt>Port</tt> is the port number at the recipient. 341<tt>Port</tt> is the port number at the recipient.
@@ -337,9 +370,9 @@ object or vice versa.
337For connected objects, outgoing datagrams 370For connected objects, outgoing datagrams
338will be sent to the specified peer, and datagrams received from 371will be sent to the specified peer, and datagrams received from
339other peers will be discarded by the OS. Connected UDP objects must 372other peers will be discarded by the OS. Connected UDP objects must
340use the <a href="#send"><tt>send</tt></a> and 373use the <a href="#send"><tt>send</tt></a> and
341<a href="#receive"><tt>receive</tt></a> methods instead of 374<a href="#receive"><tt>receive</tt></a> methods instead of
342<a href="#sendto"><tt>sendto</tt></a> and 375<a href="#sendto"><tt>sendto</tt></a> and
343<a href="#receivefrom"><tt>receivefrom</tt></a>. 376<a href="#receivefrom"><tt>receivefrom</tt></a>.
344</p> 377</p>
345 378
@@ -421,16 +454,16 @@ only modify an option if you are sure you need it.</p>
421name, and <tt>value</tt> depends on the option being set: 454name, and <tt>value</tt> depends on the option being set:
422</p> 455</p>
423 456
424<ul> 457<ul>
425<li> '<tt>dontroute</tt>': Indicates that outgoing 458<li> '<tt>dontroute</tt>': Indicates that outgoing
426messages should bypass the standard routing facilities. 459messages should bypass the standard routing facilities.
427Receives a boolean value; 460Receives a boolean value;
428<li> '<tt>broadcast</tt>': Requests permission to send 461<li> '<tt>broadcast</tt>': Requests permission to send
429broadcast datagrams on the socket. 462broadcast datagrams on the socket.
430Receives a boolean value; 463Receives a boolean value;
431<li> '<tt>reuseaddr</tt>': Indicates that the rules used in 464<li> '<tt>reuseaddr</tt>': Indicates that the rules used in
432validating addresses supplied in a <tt>bind()</tt> call 465validating addresses supplied in a <tt>bind()</tt> call
433should allow reuse of local addresses. 466should allow reuse of local addresses.
434Receives a boolean value; 467Receives a boolean value;
435<li> '<tt>reuseport</tt>': Allows completely duplicate 468<li> '<tt>reuseport</tt>': Allows completely duplicate
436bindings by multiple processes if they all set 469bindings by multiple processes if they all set
@@ -442,7 +475,7 @@ datagram is delivered to the sending host as long as it is a
442member of the multicast group. 475member of the multicast group.
443Receives a boolean value; 476Receives a boolean value;
444<li> '<tt>ipv6-v6only</tt>': 477<li> '<tt>ipv6-v6only</tt>':
445Specifies whether to restrict <tt>inet6</tt> sockets to 478Specifies whether to restrict <tt>inet6</tt> sockets to
446sending and receiving only IPv6 packets. 479sending and receiving only IPv6 packets.
447Receive a boolean value; 480Receive a boolean value;
448<li> '<tt>ip-multicast-if</tt>': 481<li> '<tt>ip-multicast-if</tt>':
@@ -451,9 +484,9 @@ are sent.
451Receives an IP address; 484Receives an IP address;
452<li> '<tt>ip-multicast-ttl</tt>': 485<li> '<tt>ip-multicast-ttl</tt>':
453Sets the Time To Live in the IP header for outgoing 486Sets the Time To Live in the IP header for outgoing
454multicast datagrams. 487multicast datagrams.
455Receives a number; 488Receives a number;
456<li> '<tt>ip-add-membership</tt>': 489<li> '<tt>ip-add-membership</tt>':
457Joins the multicast group specified. 490Joins the multicast group specified.
458Receives a table with fields 491Receives a table with fields
459<tt>multiaddr</tt> and <tt>interface</tt>, each containing an 492<tt>multiaddr</tt> and <tt>interface</tt>, each containing an
@@ -463,7 +496,7 @@ group specified.
463Receives a table with fields 496Receives a table with fields
464<tt>multiaddr</tt> and <tt>interface</tt>, each containing an 497<tt>multiaddr</tt> and <tt>interface</tt>, each containing an
465IP address. 498IP address.
466</ul> 499</ul>
467 500
468<p class="return"> 501<p class="return">
469The method returns 1 in case of success, or 502The method returns 1 in case of success, or
@@ -482,14 +515,14 @@ unconnected:<b>settimeout(</b>value<b>)</b>
482</p> 515</p>
483 516
484<p class="description"> 517<p class="description">
485Changes the timeout values for the object. By default, the 518Changes the timeout values for the object. By default, the
486<a href="#receive"><tt>receive</tt></a> and 519<a href="#receive"><tt>receive</tt></a> and
487<a href="#receivefrom"><tt>receivefrom</tt></a> 520<a href="#receivefrom"><tt>receivefrom</tt></a>
488operations are blocking. That is, any call to the methods will block 521operations are blocking. That is, any call to the methods will block
489indefinitely, until data arrives. The <tt>settimeout</tt> function defines 522indefinitely, until data arrives. The <tt>settimeout</tt> function defines
490a limit on the amount of time the functions can block. When a timeout is 523a limit on the amount of time the functions can block. When a timeout is
491set and the specified amount of time has elapsed, the affected methods 524set and the specified amount of time has elapsed, the affected methods
492give up and fail with an error code. 525give up and fail with an error code.
493</p> 526</p>
494 527
495<p class="parameters"> 528<p class="parameters">
@@ -524,7 +557,7 @@ imperative nature obvious.
524<a href="index.html#download">download</a> &middot; 557<a href="index.html#download">download</a> &middot;
525<a href="installation.html">installation</a> &middot; 558<a href="installation.html">installation</a> &middot;
526<a href="introduction.html">introduction</a> &middot; 559<a href="introduction.html">introduction</a> &middot;
527<a href="reference.html">reference</a> 560<a href="reference.html">reference</a>
528</p> 561</p>
529<p> 562<p>
530<small> 563<small>