New agnostic IPv4 IPv6 functions.
Also dealing with EPROTOTYPE Yosemite seems to be throwing at us for no reason.
This commit is contained in:
parent
b211838648
commit
96965b179c
14 changed files with 399 additions and 352 deletions
159
doc/udp.html
159
doc/udp.html
|
@ -4,7 +4,7 @@
|
|||
|
||||
<head>
|
||||
<meta name="description" content="LuaSocket: The UDP support">
|
||||
<meta name="keywords" content="Lua, LuaSocket, Socket, UDP, Library, Network, Support">
|
||||
<meta name="keywords" content="Lua, LuaSocket, Socket, UDP, Library, Network, Support">
|
||||
<title>LuaSocket: UDP support</title>
|
||||
<link rel="stylesheet" href="reference.css" type="text/css">
|
||||
</head>
|
||||
|
@ -28,7 +28,7 @@
|
|||
<a href="index.html#download">download</a> ·
|
||||
<a href="installation.html">installation</a> ·
|
||||
<a href="introduction.html">introduction</a> ·
|
||||
<a href="reference.html">reference</a>
|
||||
<a href="reference.html">reference</a>
|
||||
</p>
|
||||
</center>
|
||||
<hr>
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
<!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
<h2 id="udp">UDP</h2>
|
||||
<h2 id="udp">UDP</h2>
|
||||
|
||||
<!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
|
@ -46,19 +46,56 @@ socket.<b>udp()</b>
|
|||
</p>
|
||||
|
||||
<p class="description">
|
||||
Creates and returns an unconnected IPv4 UDP object.
|
||||
Unconnected objects support the
|
||||
<a href="#sendto"><tt>sendto</tt></a>,
|
||||
<a href="#receive"><tt>receive</tt></a>,
|
||||
<a href="#receivefrom"><tt>receivefrom</tt></a>,
|
||||
<a href="#getoption"><tt>getoption</tt></a>,
|
||||
<a href="#getsockname"><tt>getsockname</tt></a>,
|
||||
<a href="#setoption"><tt>setoption</tt></a>,
|
||||
<a href="#settimeout"><tt>settimeout</tt></a>,
|
||||
<a href="#setpeername"><tt>setpeername</tt></a>,
|
||||
<a href="#setsockname"><tt>setsockname</tt></a>, and
|
||||
<a href="#close"><tt>close</tt></a>.
|
||||
The <a href="#setpeername"><tt>setpeername</tt></a>
|
||||
Creates and returns an unconnected UDP object.
|
||||
Unconnected objects support the
|
||||
<a href="#sendto"><tt>sendto</tt></a>,
|
||||
<a href="#receive"><tt>receive</tt></a>,
|
||||
<a href="#receivefrom"><tt>receivefrom</tt></a>,
|
||||
<a href="#getoption"><tt>getoption</tt></a>,
|
||||
<a href="#getsockname"><tt>getsockname</tt></a>,
|
||||
<a href="#setoption"><tt>setoption</tt></a>,
|
||||
<a href="#settimeout"><tt>settimeout</tt></a>,
|
||||
<a href="#setpeername"><tt>setpeername</tt></a>,
|
||||
<a href="#setsockname"><tt>setsockname</tt></a>, and
|
||||
<a href="#close"><tt>close</tt></a>.
|
||||
The <a href="#setpeername"><tt>setpeername</tt></a>
|
||||
is used to connect the object.
|
||||
</p>
|
||||
|
||||
<p class="return">
|
||||
In case of success, a new unconnected UDP object
|
||||
returned. In case of error, <b><tt>nil</tt></b> is returned, followed by
|
||||
an error message.
|
||||
</p>
|
||||
|
||||
<p class=note>
|
||||
Note: The choice between IPv4 and IPv6 happens during a call to
|
||||
<a href=#sendto><tt>sendto</tt></a>, <a
|
||||
href=#setpeername><tt>setpeername</tt></a>, or <a
|
||||
href=#setsockname><tt>sockname</tt></a>, depending on the address
|
||||
family obtained from the resolver.
|
||||
</p>
|
||||
|
||||
<!-- socket.udp4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
<p class="name" id="socket.udp">
|
||||
socket.<b>udp4()</b>
|
||||
</p>
|
||||
|
||||
<p class="description">
|
||||
Creates and returns an unconnected IPv4 UDP object.
|
||||
Unconnected objects support the
|
||||
<a href="#sendto"><tt>sendto</tt></a>,
|
||||
<a href="#receive"><tt>receive</tt></a>,
|
||||
<a href="#receivefrom"><tt>receivefrom</tt></a>,
|
||||
<a href="#getoption"><tt>getoption</tt></a>,
|
||||
<a href="#getsockname"><tt>getsockname</tt></a>,
|
||||
<a href="#setoption"><tt>setoption</tt></a>,
|
||||
<a href="#settimeout"><tt>settimeout</tt></a>,
|
||||
<a href="#setpeername"><tt>setpeername</tt></a>,
|
||||
<a href="#setsockname"><tt>setsockname</tt></a>, and
|
||||
<a href="#close"><tt>close</tt></a>.
|
||||
The <a href="#setpeername"><tt>setpeername</tt></a>
|
||||
is used to connect the object.
|
||||
</p>
|
||||
|
||||
|
@ -75,19 +112,19 @@ socket.<b>udp6()</b>
|
|||
</p>
|
||||
|
||||
<p class="description">
|
||||
Creates and returns an unconnected IPv6 UDP object.
|
||||
Unconnected objects support the
|
||||
<a href="#sendto"><tt>sendto</tt></a>,
|
||||
<a href="#receive"><tt>receive</tt></a>,
|
||||
<a href="#receivefrom"><tt>receivefrom</tt></a>,
|
||||
<a href="#getoption"><tt>getoption</tt></a>,
|
||||
<a href="#getsockname"><tt>getsockname</tt></a>,
|
||||
<a href="#setoption"><tt>setoption</tt></a>,
|
||||
<a href="#settimeout"><tt>settimeout</tt></a>,
|
||||
<a href="#setpeername"><tt>setpeername</tt></a>,
|
||||
<a href="#setsockname"><tt>setsockname</tt></a>, and
|
||||
<a href="#close"><tt>close</tt></a>.
|
||||
The <a href="#setpeername"><tt>setpeername</tt></a>
|
||||
Creates and returns an unconnected IPv6 UDP object.
|
||||
Unconnected objects support the
|
||||
<a href="#sendto"><tt>sendto</tt></a>,
|
||||
<a href="#receive"><tt>receive</tt></a>,
|
||||
<a href="#receivefrom"><tt>receivefrom</tt></a>,
|
||||
<a href="#getoption"><tt>getoption</tt></a>,
|
||||
<a href="#getsockname"><tt>getsockname</tt></a>,
|
||||
<a href="#setoption"><tt>setoption</tt></a>,
|
||||
<a href="#settimeout"><tt>settimeout</tt></a>,
|
||||
<a href="#setpeername"><tt>setpeername</tt></a>,
|
||||
<a href="#setsockname"><tt>setsockname</tt></a>, and
|
||||
<a href="#close"><tt>close</tt></a>.
|
||||
The <a href="#setpeername"><tt>setpeername</tt></a>
|
||||
is used to connect the object.
|
||||
</p>
|
||||
|
||||
|
@ -102,10 +139,6 @@ Note: The TCP object returned will have the option
|
|||
"<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
<!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
<p class="name" id="close">
|
||||
|
@ -142,10 +175,10 @@ associated with a connected UDP object.
|
|||
|
||||
|
||||
<p class=return>
|
||||
Returns a string with the IP address of the peer, the
|
||||
port number that peer is using for the connection,
|
||||
and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
|
||||
In case of error, the method returns <b><tt>nil</tt></b>.
|
||||
Returns a string with the IP address of the peer, the
|
||||
port number that peer is using for the connection,
|
||||
and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
|
||||
In case of error, the method returns <b><tt>nil</tt></b>.
|
||||
</p>
|
||||
|
||||
<p class="note">
|
||||
|
@ -165,9 +198,9 @@ Returns the local address information associated to the object.
|
|||
|
||||
|
||||
<p class=return>
|
||||
The method returns a string with local IP address, a number with
|
||||
the local port,
|
||||
and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
|
||||
The method returns a string with local IP address, a number with
|
||||
the local port,
|
||||
and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
|
||||
In case of error, the method returns <b><tt>nil</tt></b>.
|
||||
</p>
|
||||
|
||||
|
@ -217,7 +250,7 @@ unconnected:<b>receivefrom(</b>[size]<b>)</b>
|
|||
</p>
|
||||
|
||||
<p class="description">
|
||||
Works exactly as the <a href="#receive"><tt>receive</tt></a>
|
||||
Works exactly as the <a href="#receive"><tt>receive</tt></a>
|
||||
method, except it returns the IP
|
||||
address and port as extra return values (and is therefore slightly less
|
||||
efficient).
|
||||
|
@ -236,7 +269,7 @@ See <a href=#setoption><tt>setoption</tt></a> for
|
|||
description of the option names and values.
|
||||
</p>
|
||||
|
||||
<p class="parameters"><tt>Option</tt> is a string with the option name.
|
||||
<p class="parameters"><tt>Option</tt> is a string with the option name.
|
||||
<ul>
|
||||
<li> '<tt>dontroute</tt>'
|
||||
<li> '<tt>broadcast</tt>'
|
||||
|
@ -246,9 +279,9 @@ description of the option names and values.
|
|||
<li> '<tt>ipv6-v6only</tt>'
|
||||
<li> '<tt>ip-multicast-if</tt>'
|
||||
<li> '<tt>ip-multicast-ttl</tt>'
|
||||
<li> '<tt>ip-add-membership</tt>'
|
||||
<li> '<tt>ip-add-membership</tt>'
|
||||
<li> '<tt>ip-drop-membership</tt>'
|
||||
</ul>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p class=return>
|
||||
|
@ -268,7 +301,7 @@ Sends a datagram to the UDP peer of a connected object.
|
|||
</p>
|
||||
|
||||
<p class="parameters">
|
||||
<tt>Datagram</tt> is a string with the datagram contents.
|
||||
<tt>Datagram</tt> is a string with the datagram contents.
|
||||
The maximum datagram size for UDP is 64K minus IP layer overhead.
|
||||
However datagrams larger than the link layer packet size will be
|
||||
fragmented, which may deteriorate performance and/or reliability.
|
||||
|
@ -298,11 +331,11 @@ Sends a datagram to the specified IP address and port number.
|
|||
|
||||
<p class="parameters">
|
||||
<tt>Datagram</tt> is a string with the
|
||||
datagram contents.
|
||||
datagram contents.
|
||||
The maximum datagram size for UDP is 64K minus IP layer overhead.
|
||||
However datagrams larger than the link layer packet size will be
|
||||
fragmented, which may deteriorate performance and/or reliability.
|
||||
<tt>Ip</tt> is the IP address of the recipient.
|
||||
<tt>Ip</tt> is the IP address of the recipient.
|
||||
Host names are <em>not</em> allowed for performance reasons.
|
||||
|
||||
<tt>Port</tt> is the port number at the recipient.
|
||||
|
@ -337,9 +370,9 @@ object or vice versa.
|
|||
For connected objects, outgoing datagrams
|
||||
will be sent to the specified peer, and datagrams received from
|
||||
other peers will be discarded by the OS. Connected UDP objects must
|
||||
use the <a href="#send"><tt>send</tt></a> and
|
||||
<a href="#receive"><tt>receive</tt></a> methods instead of
|
||||
<a href="#sendto"><tt>sendto</tt></a> and
|
||||
use the <a href="#send"><tt>send</tt></a> and
|
||||
<a href="#receive"><tt>receive</tt></a> methods instead of
|
||||
<a href="#sendto"><tt>sendto</tt></a> and
|
||||
<a href="#receivefrom"><tt>receivefrom</tt></a>.
|
||||
</p>
|
||||
|
||||
|
@ -421,16 +454,16 @@ only modify an option if you are sure you need it.</p>
|
|||
name, and <tt>value</tt> depends on the option being set:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<ul>
|
||||
<li> '<tt>dontroute</tt>': Indicates that outgoing
|
||||
messages should bypass the standard routing facilities.
|
||||
Receives a boolean value;
|
||||
<li> '<tt>broadcast</tt>': Requests permission to send
|
||||
<li> '<tt>broadcast</tt>': Requests permission to send
|
||||
broadcast datagrams on the socket.
|
||||
Receives a boolean value;
|
||||
<li> '<tt>reuseaddr</tt>': Indicates that the rules used in
|
||||
validating addresses supplied in a <tt>bind()</tt> call
|
||||
should allow reuse of local addresses.
|
||||
validating addresses supplied in a <tt>bind()</tt> call
|
||||
should allow reuse of local addresses.
|
||||
Receives a boolean value;
|
||||
<li> '<tt>reuseport</tt>': Allows completely duplicate
|
||||
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
|
|||
member of the multicast group.
|
||||
Receives a boolean value;
|
||||
<li> '<tt>ipv6-v6only</tt>':
|
||||
Specifies whether to restrict <tt>inet6</tt> sockets to
|
||||
Specifies whether to restrict <tt>inet6</tt> sockets to
|
||||
sending and receiving only IPv6 packets.
|
||||
Receive a boolean value;
|
||||
<li> '<tt>ip-multicast-if</tt>':
|
||||
|
@ -451,9 +484,9 @@ are sent.
|
|||
Receives an IP address;
|
||||
<li> '<tt>ip-multicast-ttl</tt>':
|
||||
Sets the Time To Live in the IP header for outgoing
|
||||
multicast datagrams.
|
||||
multicast datagrams.
|
||||
Receives a number;
|
||||
<li> '<tt>ip-add-membership</tt>':
|
||||
<li> '<tt>ip-add-membership</tt>':
|
||||
Joins the multicast group specified.
|
||||
Receives a table with fields
|
||||
<tt>multiaddr</tt> and <tt>interface</tt>, each containing an
|
||||
|
@ -463,7 +496,7 @@ group specified.
|
|||
Receives a table with fields
|
||||
<tt>multiaddr</tt> and <tt>interface</tt>, each containing an
|
||||
IP address.
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<p class="return">
|
||||
The method returns 1 in case of success, or
|
||||
|
@ -482,14 +515,14 @@ unconnected:<b>settimeout(</b>value<b>)</b>
|
|||
</p>
|
||||
|
||||
<p class="description">
|
||||
Changes the timeout values for the object. By default, the
|
||||
<a href="#receive"><tt>receive</tt></a> and
|
||||
<a href="#receivefrom"><tt>receivefrom</tt></a>
|
||||
Changes the timeout values for the object. By default, the
|
||||
<a href="#receive"><tt>receive</tt></a> and
|
||||
<a href="#receivefrom"><tt>receivefrom</tt></a>
|
||||
operations are blocking. That is, any call to the methods will block
|
||||
indefinitely, until data arrives. The <tt>settimeout</tt> function defines
|
||||
a limit on the amount of time the functions can block. When a timeout is
|
||||
set and the specified amount of time has elapsed, the affected methods
|
||||
give up and fail with an error code.
|
||||
give up and fail with an error code.
|
||||
</p>
|
||||
|
||||
<p class="parameters">
|
||||
|
@ -524,7 +557,7 @@ imperative nature obvious.
|
|||
<a href="index.html#download">download</a> ·
|
||||
<a href="installation.html">installation</a> ·
|
||||
<a href="introduction.html">introduction</a> ·
|
||||
<a href="reference.html">reference</a>
|
||||
<a href="reference.html">reference</a>
|
||||
</p>
|
||||
<p>
|
||||
<small>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue