diff options
| author | Diego Nehab <diego.nehab@gmail.com> | 2012-04-17 01:15:26 +0800 |
|---|---|---|
| committer | Diego Nehab <diego.nehab@gmail.com> | 2012-04-17 01:15:26 +0800 |
| commit | f37e0260261f7691246429d227cf7124c291e8b1 (patch) | |
| tree | 7e84322c8852d4227e36958af1132a4588f64795 /doc/udp.html | |
| parent | b3c4f46179ed5b27ca76a824f8730fa50dbaae0b (diff) | |
| download | luasocket-f37e0260261f7691246429d227cf7124c291e8b1.tar.gz luasocket-f37e0260261f7691246429d227cf7124c291e8b1.tar.bz2 luasocket-f37e0260261f7691246429d227cf7124c291e8b1.zip | |
First stab at documenation
Update Lua and Luasocket version in samples and in documentation
Documented ipv5_v6only default option being set
Documented tcp6 and udp6
Documented dns.getaddrinfo
Documented zero-sized datagram change?
Documented getoption
Diffstat (limited to 'doc/udp.html')
| -rw-r--r-- | doc/udp.html | 143 |
1 files changed, 130 insertions, 13 deletions
diff --git a/doc/udp.html b/doc/udp.html index eca881d..4a334b7 100644 --- a/doc/udp.html +++ b/doc/udp.html | |||
| @@ -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,10 +46,12 @@ socket.<b>udp()</b> | |||
| 46 | </p> | 46 | </p> |
| 47 | 47 | ||
| 48 | <p class="description"> | 48 | <p class="description"> |
| 49 | Creates and returns an unconnected UDP object. Unconnected objects support the | 49 | Creates and returns an unconnected IPv4 UDP object. |
| 50 | Unconnected objects support the | ||
| 50 | <a href="#sendto"><tt>sendto</tt></a>, | 51 | <a href="#sendto"><tt>sendto</tt></a>, |
| 51 | <a href="#receive"><tt>receive</tt></a>, | 52 | <a href="#receive"><tt>receive</tt></a>, |
| 52 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | 53 | <a href="#receivefrom"><tt>receivefrom</tt></a>, |
| 54 | <a href="#getoption"><tt>getoption</tt></a>, | ||
| 53 | <a href="#getsockname"><tt>getsockname</tt></a>, | 55 | <a href="#getsockname"><tt>getsockname</tt></a>, |
| 54 | <a href="#setoption"><tt>setoption</tt></a>, | 56 | <a href="#setoption"><tt>setoption</tt></a>, |
| 55 | <a href="#settimeout"><tt>settimeout</tt></a>, | 57 | <a href="#settimeout"><tt>settimeout</tt></a>, |
| @@ -66,6 +68,44 @@ returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | |||
| 66 | an error message. | 68 | an error message. |
| 67 | </p> | 69 | </p> |
| 68 | 70 | ||
| 71 | <!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 72 | |||
| 73 | <p class="name" id="socket.udp6"> | ||
| 74 | socket.<b>udp6()</b> | ||
| 75 | </p> | ||
| 76 | |||
| 77 | <p class="description"> | ||
| 78 | Creates and returns an unconnected IPv6 UDP object. | ||
| 79 | Unconnected objects support the | ||
| 80 | <a href="#sendto"><tt>sendto</tt></a>, | ||
| 81 | <a href="#receive"><tt>receive</tt></a>, | ||
| 82 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | ||
| 83 | <a href="#getoption"><tt>getoption</tt></a>, | ||
| 84 | <a href="#getsockname"><tt>getsockname</tt></a>, | ||
| 85 | <a href="#setoption"><tt>setoption</tt></a>, | ||
| 86 | <a href="#settimeout"><tt>settimeout</tt></a>, | ||
| 87 | <a href="#setpeername"><tt>setpeername</tt></a>, | ||
| 88 | <a href="#setsockname"><tt>setsockname</tt></a>, and | ||
| 89 | <a href="#close"><tt>close</tt></a>. | ||
| 90 | The <a href="#setpeername"><tt>setpeername</tt></a> | ||
| 91 | is used to connect the object. | ||
| 92 | </p> | ||
| 93 | |||
| 94 | <p class="return"> | ||
| 95 | In case of success, a new unconnected UDP object | ||
| 96 | returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | ||
| 97 | an error message. | ||
| 98 | </p> | ||
| 99 | |||
| 100 | <p class=note> | ||
| 101 | Note: The TCP object returned will have the option | ||
| 102 | "<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>. | ||
| 103 | </p> | ||
| 104 | |||
| 105 | |||
| 106 | |||
| 107 | <!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 108 | |||
| 69 | <!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 109 | <!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 70 | 110 | ||
| 71 | <p class="name" id="close"> | 111 | <p class="name" id="close"> |
| @@ -177,6 +217,40 @@ address and port as extra return values (and is therefore slightly less | |||
| 177 | efficient). | 217 | efficient). |
| 178 | </p> | 218 | </p> |
| 179 | 219 | ||
| 220 | <!-- getoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 221 | |||
| 222 | <p class="name" id="getoption"> | ||
| 223 | connected:<b>getoption()</b><br> | ||
| 224 | unconnected:<b>getoption()</b> | ||
| 225 | </p> | ||
| 226 | |||
| 227 | <p class="description"> | ||
| 228 | Gets an option value from the UDP object. | ||
| 229 | See <a href=#setoption><tt>setoption</tt></a> for | ||
| 230 | description of the option names and values. | ||
| 231 | </p> | ||
| 232 | |||
| 233 | <p class="parameters"><tt>Option</tt> is a string with the option name. | ||
| 234 | <ul> | ||
| 235 | <li> '<tt>dontroute</tt>' | ||
| 236 | <li> '<tt>broadcast</tt>' | ||
| 237 | <li> '<tt>reuseaddr</tt>' | ||
| 238 | <li> '<tt>reuseport</tt>' | ||
| 239 | <li> '<tt>ip-multicast-loop</tt>' | ||
| 240 | <li> '<tt>ipv6-v6only</tt>' | ||
| 241 | <li> '<tt>ip-multicast-if</tt>' | ||
| 242 | <li> '<tt>ip-multicast-ttl</tt>' | ||
| 243 | <li> '<tt>ip-add-membership</tt>' | ||
| 244 | <li> '<tt>ip-drop-membership</tt>' | ||
| 245 | </ul> | ||
| 246 | </p> | ||
| 247 | |||
| 248 | <p class=return> | ||
| 249 | The method returns the option <tt>value</tt> in case of | ||
| 250 | success, or | ||
| 251 | <b><tt>nil</tt></b> followed by an error message otherwise. | ||
| 252 | </p> | ||
| 253 | |||
| 180 | <!-- send ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 254 | <!-- send ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 181 | 255 | ||
| 182 | <p class="name" id="send"> | 256 | <p class="name" id="send"> |
| @@ -284,6 +358,15 @@ is recommended when the same peer is used for several transmissions | |||
| 284 | and can result in up to 30% performance gains. | 358 | and can result in up to 30% performance gains. |
| 285 | </p> | 359 | </p> |
| 286 | 360 | ||
| 361 | <p class=note> | ||
| 362 | Note: Starting with LuaSocket 2.1, the host name resolution | ||
| 363 | depends on whether the socket was created by <a | ||
| 364 | href=#socket.udp><tt>socket.udp</tt></a> or <a | ||
| 365 | href=#socket.udp6><tt>socket.udp6</tt></a>. Addresses from | ||
| 366 | the appropriate family are tried in succession until the | ||
| 367 | first success or until the last failure. | ||
| 368 | </p> | ||
| 369 | |||
| 287 | <!-- setsockname +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 370 | <!-- setsockname +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 288 | 371 | ||
| 289 | <p class="name" id="setsockname"> | 372 | <p class="name" id="setsockname"> |
| @@ -332,23 +415,57 @@ only modify an option if you are sure you need it.</p> | |||
| 332 | name, and <tt>value</tt> depends on the option being set: | 415 | name, and <tt>value</tt> depends on the option being set: |
| 333 | </p> | 416 | </p> |
| 334 | 417 | ||
| 335 | <ul> | 418 | <ul> |
| 336 | <li>'<tt>dontroute</tt>': Setting this option to <tt>true</tt> | 419 | <li> '<tt>dontroute</tt>': Indicates that outgoing |
| 337 | indicates that outgoing messages should bypass the standard routing | 420 | messages should bypass the standard routing facilities. |
| 338 | facilities;</li> | 421 | Receives a boolean value; |
| 339 | <li>'<tt>broadcast</tt>': Setting this option to <tt>true</tt> | 422 | <li> '<tt>broadcast</tt>': Requests permission to send |
| 340 | requests permission to send broadcast datagrams on the | 423 | broadcast datagrams on the socket. |
| 341 | socket.</li> | 424 | Receives a boolean value; |
| 342 | </ul> | 425 | <li> '<tt>reuseaddr</tt>': Indicates that the rules used in |
| 426 | validating addresses supplied in a <tt>bind()</tt> call | ||
| 427 | should allow reuse of local addresses. | ||
| 428 | Receives a boolean value; | ||
| 429 | <li> '<tt>reuseport</tt>': Allows completely duplicate | ||
| 430 | bindings by multiple processes if they all set | ||
| 431 | '<tt>reuseport</tt>' before binding the port. | ||
| 432 | Receives a boolean value; | ||
| 433 | <li> '<tt>ip-multicast-loop</tt>': | ||
| 434 | Specifies whether or not a copy of an outgoing multicast | ||
| 435 | datagram is delivered to the sending host as long as it is a | ||
| 436 | member of the multicast group. | ||
| 437 | Receives a boolean value; | ||
| 438 | <li> '<tt>ipv6-v6only</tt>': | ||
| 439 | Specifies whether to restrict <tt>inet6</tt> sockets to | ||
| 440 | sending and receiving only IPv6 packets. | ||
| 441 | Receive a boolean value; | ||
| 442 | <li> '<tt>ip-multicast-if</tt>': | ||
| 443 | Sets the interface over which outgoing multicast datagrams | ||
| 444 | are sent. | ||
| 445 | Receives an IP address; | ||
| 446 | <li> '<tt>ip-multicast-ttl</tt>': | ||
| 447 | Sets the Time To Live in the IP header for outgoing | ||
| 448 | multicast datagrams. | ||
| 449 | Receives a number; | ||
| 450 | <li> '<tt>ip-add-membership</tt>': | ||
| 451 | Joins the multicast group specified. | ||
| 452 | Receives a table with fields | ||
| 453 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an | ||
| 454 | IP address; | ||
| 455 | <li> '<tt>ip-drop-membership</tt>': Leaves the multicast | ||
| 456 | group specified. | ||
| 457 | Receives a table with fields | ||
| 458 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an | ||
| 459 | IP address. | ||
| 460 | </ul> | ||
| 343 | 461 | ||
| 344 | <p class="return"> | 462 | <p class="return"> |
| 345 | The method returns 1 in case of success, or | 463 | The method returns 1 in case of success, or |
| 346 | <b><tt>nil</tt></b> followed by an error message otherwise. | 464 | <b><tt>nil</tt></b> followed by an error message otherwise. |
| 347 | </p> | 465 | </p> |
| 348 | 466 | ||
| 349 | <p class="note"> | 467 | <p class=note> |
| 350 | Note: The descriptions above come from the man | 468 | Note: The descriptions above come from the man pages. |
| 351 | pages. | ||
| 352 | </p> | 469 | </p> |
| 353 | 470 | ||
| 354 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 471 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
