diff options
author | Diego Nehab <diego@impa.br> | 2015-08-22 19:52:01 -0300 |
---|---|---|
committer | Diego Nehab <diego@impa.br> | 2015-08-22 19:52:01 -0300 |
commit | 96965b179c7311f850f72a8629b9ba6d3a31d117 (patch) | |
tree | 05c93629654f686a99ee8923ef2361b7d2244ca8 /doc/udp.html | |
parent | b211838648c1cb092e96e3ae721932a212808d96 (diff) | |
download | luasocket-96965b179c7311f850f72a8629b9ba6d3a31d117.tar.gz luasocket-96965b179c7311f850f72a8629b9ba6d3a31d117.tar.bz2 luasocket-96965b179c7311f850f72a8629b9ba6d3a31d117.zip |
New agnostic IPv4 IPv6 functions.
Also dealing with EPROTOTYPE Yosemite seems to be throwing
at us for no reason.
Diffstat (limited to 'doc/udp.html')
-rw-r--r-- | doc/udp.html | 159 |
1 files changed, 96 insertions, 63 deletions
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> · | 28 | <a href="index.html#download">download</a> · |
29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
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"> |
49 | Creates and returns an unconnected IPv4 UDP object. | 49 | Creates and returns an unconnected UDP object. |
50 | Unconnected objects support the | 50 | Unconnected 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>. |
61 | The <a href="#setpeername"><tt>setpeername</tt></a> | 61 | The <a href="#setpeername"><tt>setpeername</tt></a> |
62 | is used to connect the object. | ||
63 | </p> | ||
64 | |||
65 | <p class="return"> | ||
66 | In case of success, a new unconnected UDP object | ||
67 | returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | ||
68 | an error message. | ||
69 | </p> | ||
70 | |||
71 | <p class=note> | ||
72 | Note: The choice between IPv4 and IPv6 happens during a call to | ||
73 | <a href=#sendto><tt>sendto</tt></a>, <a | ||
74 | href=#setpeername><tt>setpeername</tt></a>, or <a | ||
75 | href=#setsockname><tt>sockname</tt></a>, depending on the address | ||
76 | family obtained from the resolver. | ||
77 | </p> | ||
78 | |||
79 | <!-- socket.udp4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
80 | |||
81 | <p class="name" id="socket.udp"> | ||
82 | socket.<b>udp4()</b> | ||
83 | </p> | ||
84 | |||
85 | <p class="description"> | ||
86 | Creates and returns an unconnected IPv4 UDP object. | ||
87 | Unconnected 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>. | ||
98 | The <a href="#setpeername"><tt>setpeername</tt></a> | ||
62 | is used to connect the object. | 99 | is 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"> |
78 | Creates and returns an unconnected IPv6 UDP object. | 115 | Creates and returns an unconnected IPv6 UDP object. |
79 | Unconnected objects support the | 116 | Unconnected 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>. |
90 | The <a href="#setpeername"><tt>setpeername</tt></a> | 127 | The <a href="#setpeername"><tt>setpeername</tt></a> |
91 | is used to connect the object. | 128 | is 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> |
145 | Returns a string with the IP address of the peer, the | 178 | Returns a string with the IP address of the peer, the |
146 | port number that peer is using for the connection, | 179 | port number that peer is using for the connection, |
147 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). | 180 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). |
148 | In case of error, the method returns <b><tt>nil</tt></b>. | 181 | In 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> |
168 | The method returns a string with local IP address, a number with | 201 | The method returns a string with local IP address, a number with |
169 | the local port, | 202 | the local port, |
170 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). | 203 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). |
171 | In case of error, the method returns <b><tt>nil</tt></b>. | 204 | In 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"> |
220 | Works exactly as the <a href="#receive"><tt>receive</tt></a> | 253 | Works exactly as the <a href="#receive"><tt>receive</tt></a> |
221 | method, except it returns the IP | 254 | method, except it returns the IP |
222 | address and port as extra return values (and is therefore slightly less | 255 | address and port as extra return values (and is therefore slightly less |
223 | efficient). | 256 | efficient). |
@@ -236,7 +269,7 @@ See <a href=#setoption><tt>setoption</tt></a> for | |||
236 | description of the option names and values. | 269 | description 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. |
272 | The maximum datagram size for UDP is 64K minus IP layer overhead. | 305 | The maximum datagram size for UDP is 64K minus IP layer overhead. |
273 | However datagrams larger than the link layer packet size will be | 306 | However datagrams larger than the link layer packet size will be |
274 | fragmented, which may deteriorate performance and/or reliability. | 307 | fragmented, 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 |
301 | datagram contents. | 334 | datagram contents. |
302 | The maximum datagram size for UDP is 64K minus IP layer overhead. | 335 | The maximum datagram size for UDP is 64K minus IP layer overhead. |
303 | However datagrams larger than the link layer packet size will be | 336 | However datagrams larger than the link layer packet size will be |
304 | fragmented, which may deteriorate performance and/or reliability. | 337 | fragmented, 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. |
306 | Host names are <em>not</em> allowed for performance reasons. | 339 | Host 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. | |||
337 | For connected objects, outgoing datagrams | 370 | For connected objects, outgoing datagrams |
338 | will be sent to the specified peer, and datagrams received from | 371 | will be sent to the specified peer, and datagrams received from |
339 | other peers will be discarded by the OS. Connected UDP objects must | 372 | other peers will be discarded by the OS. Connected UDP objects must |
340 | use the <a href="#send"><tt>send</tt></a> and | 373 | use 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> | |||
421 | name, and <tt>value</tt> depends on the option being set: | 454 | name, 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 |
426 | messages should bypass the standard routing facilities. | 459 | messages should bypass the standard routing facilities. |
427 | Receives a boolean value; | 460 | Receives a boolean value; |
428 | <li> '<tt>broadcast</tt>': Requests permission to send | 461 | <li> '<tt>broadcast</tt>': Requests permission to send |
429 | broadcast datagrams on the socket. | 462 | broadcast datagrams on the socket. |
430 | Receives a boolean value; | 463 | Receives 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 |
432 | validating addresses supplied in a <tt>bind()</tt> call | 465 | validating addresses supplied in a <tt>bind()</tt> call |
433 | should allow reuse of local addresses. | 466 | should allow reuse of local addresses. |
434 | Receives a boolean value; | 467 | Receives a boolean value; |
435 | <li> '<tt>reuseport</tt>': Allows completely duplicate | 468 | <li> '<tt>reuseport</tt>': Allows completely duplicate |
436 | bindings by multiple processes if they all set | 469 | bindings by multiple processes if they all set |
@@ -442,7 +475,7 @@ datagram is delivered to the sending host as long as it is a | |||
442 | member of the multicast group. | 475 | member of the multicast group. |
443 | Receives a boolean value; | 476 | Receives a boolean value; |
444 | <li> '<tt>ipv6-v6only</tt>': | 477 | <li> '<tt>ipv6-v6only</tt>': |
445 | Specifies whether to restrict <tt>inet6</tt> sockets to | 478 | Specifies whether to restrict <tt>inet6</tt> sockets to |
446 | sending and receiving only IPv6 packets. | 479 | sending and receiving only IPv6 packets. |
447 | Receive a boolean value; | 480 | Receive a boolean value; |
448 | <li> '<tt>ip-multicast-if</tt>': | 481 | <li> '<tt>ip-multicast-if</tt>': |
@@ -451,9 +484,9 @@ are sent. | |||
451 | Receives an IP address; | 484 | Receives an IP address; |
452 | <li> '<tt>ip-multicast-ttl</tt>': | 485 | <li> '<tt>ip-multicast-ttl</tt>': |
453 | Sets the Time To Live in the IP header for outgoing | 486 | Sets the Time To Live in the IP header for outgoing |
454 | multicast datagrams. | 487 | multicast datagrams. |
455 | Receives a number; | 488 | Receives a number; |
456 | <li> '<tt>ip-add-membership</tt>': | 489 | <li> '<tt>ip-add-membership</tt>': |
457 | Joins the multicast group specified. | 490 | Joins the multicast group specified. |
458 | Receives a table with fields | 491 | Receives 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. | |||
463 | Receives a table with fields | 496 | Receives 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 |
465 | IP address. | 498 | IP address. |
466 | </ul> | 499 | </ul> |
467 | 500 | ||
468 | <p class="return"> | 501 | <p class="return"> |
469 | The method returns 1 in case of success, or | 502 | The 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"> |
485 | Changes the timeout values for the object. By default, the | 518 | Changes 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> |
488 | operations are blocking. That is, any call to the methods will block | 521 | operations are blocking. That is, any call to the methods will block |
489 | indefinitely, until data arrives. The <tt>settimeout</tt> function defines | 522 | indefinitely, until data arrives. The <tt>settimeout</tt> function defines |
490 | a limit on the amount of time the functions can block. When a timeout is | 523 | a limit on the amount of time the functions can block. When a timeout is |
491 | set and the specified amount of time has elapsed, the affected methods | 524 | set and the specified amount of time has elapsed, the affected methods |
492 | give up and fail with an error code. | 525 | give 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> · | 557 | <a href="index.html#download">download</a> · |
525 | <a href="installation.html">installation</a> · | 558 | <a href="installation.html">installation</a> · |
526 | <a href="introduction.html">introduction</a> · | 559 | <a href="introduction.html">introduction</a> · |
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> |