aboutsummaryrefslogtreecommitdiff
path: root/doc/udp.html
diff options
context:
space:
mode:
authorDiego Nehab <diego.nehab@gmail.com>2012-04-17 01:15:26 +0800
committerDiego Nehab <diego.nehab@gmail.com>2012-04-17 01:15:26 +0800
commitf37e0260261f7691246429d227cf7124c291e8b1 (patch)
tree7e84322c8852d4227e36958af1132a4588f64795 /doc/udp.html
parentb3c4f46179ed5b27ca76a824f8730fa50dbaae0b (diff)
downloadluasocket-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.html143
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">
49Creates and returns an unconnected UDP object. Unconnected objects support the 49Creates and returns an unconnected IPv4 UDP object.
50Unconnected 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
66an error message. 68an error message.
67</p> 69</p>
68 70
71<!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
72
73<p class="name" id="socket.udp6">
74socket.<b>udp6()</b>
75</p>
76
77<p class="description">
78Creates and returns an unconnected IPv6 UDP object.
79Unconnected 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>.
90The <a href="#setpeername"><tt>setpeername</tt></a>
91is used to connect the object.
92</p>
93
94<p class="return">
95In case of success, a new unconnected UDP object
96returned. In case of error, <b><tt>nil</tt></b> is returned, followed by
97an error message.
98</p>
99
100<p class=note>
101Note: 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
177efficient). 217efficient).
178</p> 218</p>
179 219
220<!-- getoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
221
222<p class="name" id="getoption">
223connected:<b>getoption()</b><br>
224unconnected:<b>getoption()</b>
225</p>
226
227<p class="description">
228Gets an option value from the UDP object.
229See <a href=#setoption><tt>setoption</tt></a> for
230description 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>
249The method returns the option <tt>value</tt> in case of
250success, 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
284and can result in up to 30% performance gains. 358and can result in up to 30% performance gains.
285</p> 359</p>
286 360
361<p class=note>
362Note: Starting with LuaSocket 2.1, the host name resolution
363depends on whether the socket was created by <a
364href=#socket.udp><tt>socket.udp</tt></a> or <a
365href=#socket.udp6><tt>socket.udp6</tt></a>. Addresses from
366the appropriate family are tried in succession until the
367first 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>
332name, and <tt>value</tt> depends on the option being set: 415name, 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
337indicates that outgoing messages should bypass the standard routing 420messages should bypass the standard routing facilities.
338facilities;</li> 421Receives a boolean value;
339<li>'<tt>broadcast</tt>': Setting this option to <tt>true</tt> 422<li> '<tt>broadcast</tt>': Requests permission to send
340requests permission to send broadcast datagrams on the 423broadcast datagrams on the socket.
341socket.</li> 424Receives a boolean value;
342</ul> 425<li> '<tt>reuseaddr</tt>': Indicates that the rules used in
426validating addresses supplied in a <tt>bind()</tt> call
427should allow reuse of local addresses.
428Receives a boolean value;
429<li> '<tt>reuseport</tt>': Allows completely duplicate
430bindings by multiple processes if they all set
431'<tt>reuseport</tt>' before binding the port.
432Receives a boolean value;
433<li> '<tt>ip-multicast-loop</tt>':
434Specifies whether or not a copy of an outgoing multicast
435datagram is delivered to the sending host as long as it is a
436member of the multicast group.
437Receives a boolean value;
438<li> '<tt>ipv6-v6only</tt>':
439Specifies whether to restrict <tt>inet6</tt> sockets to
440sending and receiving only IPv6 packets.
441Receive a boolean value;
442<li> '<tt>ip-multicast-if</tt>':
443Sets the interface over which outgoing multicast datagrams
444are sent.
445Receives an IP address;
446<li> '<tt>ip-multicast-ttl</tt>':
447Sets the Time To Live in the IP header for outgoing
448multicast datagrams.
449Receives a number;
450<li> '<tt>ip-add-membership</tt>':
451Joins the multicast group specified.
452Receives a table with fields
453<tt>multiaddr</tt> and <tt>interface</tt>, each containing an
454IP address;
455<li> '<tt>ip-drop-membership</tt>': Leaves the multicast
456group specified.
457Receives a table with fields
458<tt>multiaddr</tt> and <tt>interface</tt>, each containing an
459IP address.
460</ul>
343 461
344<p class="return"> 462<p class="return">
345The method returns 1 in case of success, or 463The 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>
350Note: The descriptions above come from the man 468Note: The descriptions above come from the man pages.
351pages.
352</p> 469</p>
353 470
354<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 471<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->