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
This commit is contained in:
Diego Nehab 2012-04-17 01:15:26 +08:00
parent b3c4f46179
commit f37e026026
12 changed files with 367 additions and 197 deletions

73
TODO
View File

@ -1,38 +1,47 @@
- merge luaL_typeerror into auxiliar to avoid using luaL prefix? - merge luaL_typeerror into auxiliar to avoid using luaL prefix?
- document ipv5_v6only default option being set? - getsockname should also support IPv6, no?
- document bind and connect behavior based on address? - remove RCSID from files?
- document tcp6 and udp6 - shouldn't we instead make the code compatible to Lua 5.2
- document dns.getaddrinfo without any compat stuff, and use a compatibility layer to
- check getaddrinfo's output format make it work on 5.1?
- add functionality to query if object is ipv4 or 6? - why 2.1.1 rather than 2.1?
- normalize error messages to have all first capitals or not? - add what's new to manual
- what is this lua_Reg vs lua_reg business? - should there be an equivalent to tohostname for IPv6?
what is this putchar vs addchar business? - should we add service name resolution as well to
is this the compat-5.2 stuff? getaddrinfo?
- why 2.1.1 rather than 2.1? - document bind and connect behavior based on address?
- update copyright date everywhere?
- what to do about author? - add functionality to query if object is ipv4 or 6?
- any chance we can do without the compat for the final release? - update copyright date everywhere?
- are only _API symbols being exported now? - what to do about author?
it used to export all externs... - add http POST sample to manual
- document zero-sized send on udp vs. tcp?
- add http POST sample to manual
people keep asking stupid questions people keep asking stupid questions
- document unix socket and serial socket? add raw support? - documentation of dirty/getfd/setfd is problematic because of portability
if so, add tests?
- make sure unix conforms to tcp and udp style
- make sure serial conforms to tcp and udp style
does it need to use write/read instead of send/receive?
- documentation of dirty/getfd/setfd is problematic because of portability
same for unix and serial. same for unix and serial.
what to do about this? add a stronger disclaimer? what to do about this? add a stronger disclaimer?
- nice getoption! - remove references to Lua 5.0 from documentation, add 5.2?
prefix all setters with set_ and all getters with get_? - update lua and luasocket version in samples in documentation
- add what's new to manual - document headers.lua?
- remove references to Lua 5.0 from documentation, add 5.2? - fix makefile with decent defaults?
- update lua and luasocket version in samples in documentation
- document headers.lua? Done:
- fix makefile with decent defaults?
- document ipv5_v6only default option being set?
- document tcp6 and udp6
- document dns.getaddrinfo
- document zero-sized send on udp vs. tcp?
no.
- document unix socket and serial socket? add raw support?
no.
- document getoption
replace \r\n with \0xD\0xA in everything replace \r\n with \0xD\0xA in everything

View File

@ -39,12 +39,16 @@
<h2 id=dns>DNS</h2> <h2 id=dns>DNS</h2>
<p> <p>
Name resolution functions return <em>all</em> information obtained from the IPv4 name resolution functions
resolver in a table of the form: <a href=#toip><tt>dns.toip</tt></a>
and
<a href=#tohostname><tt>dns.tohostname</tt></a>
return <em>all</em> information obtained from
the resolver in a table of the form:
</p> </p>
<blockquote><tt> <blockquote><tt>
resolved = {<br> resolved4 = {<br>
&nbsp;&nbsp;name = <i>canonic-name</i>,<br> &nbsp;&nbsp;name = <i>canonic-name</i>,<br>
&nbsp;&nbsp;alias = <i>alias-list</i>,<br> &nbsp;&nbsp;alias = <i>alias-list</i>,<br>
&nbsp;&nbsp;ip = <i>ip-address-list</i><br> &nbsp;&nbsp;ip = <i>ip-address-list</i><br>
@ -55,6 +59,53 @@ resolved = {<br>
Note that the <tt>alias</tt> list can be empty. Note that the <tt>alias</tt> list can be empty.
</p> </p>
<p>
The more general name resolution function
<a href=#getaddrinfo><tt>dns.getaddrinfo</tt></a>, which
supports both IPv6 and IPv4,
returns <em>all</em> information obtained from
the resolver in a table of the form:
</p>
<blockquote><tt>
resolved6 = {<br>
&nbsp;&nbsp;[1] = {<br>
&nbsp;&nbsp;&nbsp;&nbsp;family = <i>family-name-1</i>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;addr = <i>address-1</i><br>
&nbsp;&nbsp;},<br>
&nbsp;&nbsp;...<br>
&nbsp;&nbsp;[n] = {<br>
&nbsp;&nbsp;&nbsp;&nbsp;family = <i>family-name-n</i>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;addr = <i>address-n</i><br>
&nbsp;&nbsp;}<br>
}
</tt> </blockquote>
<p>
Here, <tt>family</tt> contains the string <tt>"inet"</tt> for IPv4
addresses, and <tt>"inet6"</tt> for IPv6 addresses.
</p>
<!-- getaddrinfo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=getaddrinfo>
socket.dns.<b>getaddrinfo(</b>address<b>)</b>
</p>
<p class=description>
Converts from host name to address.
</p>
<p class=parameters>
<tt>Address</tt> can be an IPv4 or IPv6 address or host name.
</p>
<p class=return>
The function returns a table with all information returned by
the resolver. In case of error, the function returns <b><tt>nil</tt></b>
followed by an error message.
</p>
<!-- gethostname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- gethostname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=gethostname> <p class=name id=gethostname>
@ -72,7 +123,7 @@ socket.dns.<b>tohostname(</b>address<b>)</b>
</p> </p>
<p class=description> <p class=description>
Converts from IP address to host name. Converts from IPv4 address to host name.
</p> </p>
<p class=parameters> <p class=parameters>
@ -93,7 +144,7 @@ socket.dns.<b>toip(</b>address<b>)</b>
</p> </p>
<p class=description> <p class=description>
Converts from host name to IP address. Converts from host name to IPv4 address.
</p> </p>
<p class=parameters> <p class=parameters>

View File

@ -36,7 +36,7 @@
<!-- http +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- http +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2 id=http>HTTP</h2> <h2 id="http">HTTP</h2>
<p> <p>
HTTP (Hyper Text Transfer Protocol) is the protocol used to exchange HTTP (Hyper Text Transfer Protocol) is the protocol used to exchange
@ -119,7 +119,7 @@ the HTTP module:
<!-- http.request ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- http.request ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=request> <p class=name id="request">
http.<b>request(</b>url [, body]<b>)</b><br> http.<b>request(</b>url [, body]<b>)</b><br>
http.<b>request{</b><br> http.<b>request{</b><br>
&nbsp;&nbsp;url = <i>string</i>,<br> &nbsp;&nbsp;url = <i>string</i>,<br>
@ -256,7 +256,7 @@ r, c, h = http.request {
-- } -- }
</pre> </pre>
<p class=note id=post> <p class=note id="post">
Note: When sending a POST request, simple interface adds a Note: When sending a POST request, simple interface adds a
"<tt>Content-type: application/x-www-form-urlencoded</tt>" "<tt>Content-type: application/x-www-form-urlencoded</tt>"
header to the request. This is the type used by header to the request. This is the type used by
@ -264,7 +264,7 @@ HTML forms. If you need another type, use the generic
interface. interface.
</p> </p>
<p class=note id=authentication> <p class=note id="authentication">
Note: Some URLs are protected by their Note: Some URLs are protected by their
servers from anonymous download. For those URLs, the server must receive servers from anonymous download. For those URLs, the server must receive
some sort of authentication along with the request or it will deny some sort of authentication along with the request or it will deny

View File

@ -78,8 +78,8 @@ LuaSocket.
</p> </p>
<p> <p>
Copyright &copy; 2004-2007 Diego Nehab. All rights reserved. <br> Copyright &copy; 1999-2012 Diego Nehab. All rights reserved. <br>
Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a> Author: <A href="http://www.impa.br/~diego">Diego Nehab</a>
</p> </p>
<!-- download +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- download +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -87,25 +87,18 @@ Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a>
<h2 id=download>Download</h2> <h2 id=download>Download</h2>
<p> <p>
LuaSocket version 2.0.3 is now available for download! It is LuaSocket version 2.1.1-rc1 is now available for download!
compatible with Lua&nbsp;5.1, and has It is compatible with Lua&nbsp;5.1 and 5.2, and has
been tested on Windows&nbsp;XP, Linux, and Mac OS X. Chances been tested on Windows&nbsp;XP, Linux, and Mac OS X. Chances
are it works well on most UNIX distributions and Windows flavors. are it works well on most UNIX distributions and Windows flavors.
</p> </p>
<p> <p>
The library can be downloaded in source code from the The library can be downloaded in source code from the
<a href=http://luaforge.net/projects/luasocket/>LuaSocket <a href="https://github.com/diegonehab/luasocket/downloads">LuaSocket
project page</a> at LuaForge. project page</a> at GitHub. Besides the full C and Lua source code
Besides the full C and Lua source code for the library, the distribution for the library, the distribution contains several examples,
contains several examples, this user's manual and basic test procedures. this user's manual and basic test procedures.
</p>
<p>
Danilo Tuler is maintaining Win32 binaries for LuaSocket, which are also
available from LuaForge. These are compatible with the
<a href=http://luaforge.net/projects/luabinaries>LuaBinaries</a>,
also available from LuaForge.
</p> </p>
<p> Take a look at the <a <p> Take a look at the <a
@ -118,15 +111,13 @@ manual to find out how to properly install the library.
<h2 id=thanks>Special thanks</h2> <h2 id=thanks>Special thanks</h2>
<p> <p>
Throughout LuaSocket's history, many people gave suggestions This marks the first release of LuaSocket that
that helped improve it. For that, I thank the Lua community. wholeheartedly embraces the open-source development
Special thanks go to David Burgess, who has helped push the philosophy. After a long hiatus, Matthew Wild finally
library to a new level of quality and from whom I have convinced me it was time for a release including IPv6
learned a lot of stuff that doesn't show up in RFCs. and Lua 5.2 support. Special thanks to Sam Roberts, Florian
Special thanks also to Carlos Cassino, who played a big part Zeitz, and Paul Aurich, Liam Devine, and everybody else that
in the extensible design seen in the C core of LuaSocket has helped bring this library back to life.
2.0. Mike Pall has been helping a lot too! Thanks to you
all!
</p> </p>
<!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -134,30 +125,25 @@ all!
<h2 id=new>What's New</h2> <h2 id=new>What's New</h2>
<p> <p>
2.0.3 is just a bug-fix/update release. Main changes for LuaSocket&nbsp;2.1.1-rc1 are IPv6 support
and Lua&nbsp;5.2 compatibility.
</p> </p>
<ul> <ul>
<li> Fixed: manual sample of HTTP authentication now uses correct <li> Added: Compatible with Lua&nbsp;5.2 (using <tt>LUA_COMPAT_MODULE</tt>);
"authorization" header (Alexandre Ittner); <li> Added: IPv6 support;
<li> Fixed: receive() returns immediatelly if prefix can satisfy <ul>
bytes requested (M Joonas Pihlaja); <li> <tt>Socket.connect</tt> and <tt>socket.bind</tt> support IPv6 addresses;
<li> Fixed: multicast didn't work on Windows, or anywhere <li> <tt>Getpeername</tt> and <tt>getsockname</tt> support IPv6 addresses;
else for that matter (Herbert Leuwer, Adrian Sietsma); <li> New <tt>socket.tcp6</tt> and <tt>socket.udp6</tt> functions;
<li> Fixed: select() now reports an error when called with more <li> New <tt>socket.dns.getaddrinfo</tt> function;
sockets than FD_SETSIZE (Lorenzo Leonini); </ul>
<li> Fixed: manual links to home.html changed to index.html (Robert Hahn); <li> Added: <tt>getoption</tt> method;
<li> Fixed: mime.unb64() would return an empty string on results that started <li> Fixed: <tt>url.unescape</tt> was returning additional values;
with a null character (Robert Raschke); <li> Fixed: Receiving zero-length datagram is now possible;
<li> Fixed: HTTP now automatically redirects on 303 and 307 (Jonathan Gray); <li> Improved: Hidden all internal library symbols;
<li> Fixed: calling sleep() with negative numbers could <li> Improved: Better error messages;
block forever, wasting CPU. Now it returns immediately (MPB); <li> Improved: Better documentation of socket options.
<li> Improved: FTP commands are now sent in upper case to
help buggy servers (Anders Eurenius);
<li> Improved: known headers now sent in canonic
capitalization to help buggy servers (Joseph Stewart);
<li> Improved: Clarified tcp:receive() in the manual (MPB);
<li> Improved: Decent makefiles (LHF).
</ul> </ul>
<!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -166,7 +152,7 @@ all!
<p> <p>
All previous versions of the LuaSocket library can be downloaded <a All previous versions of the LuaSocket library can be downloaded <a
href="http://www.cs.princeton.edu/~diego/professional/luasocket/old"> href="http://www.impa.br/~diego/software/luasocket/old">
here</a>. Although these versions are no longer supported, they are here</a>. Although these versions are no longer supported, they are
still available for those that have compatibility issues. still available for those that have compatibility issues.
</p> </p>
@ -185,7 +171,7 @@ still available for those that have compatibility issues.
<p> <p>
<small> <small>
Last modified by Diego Nehab on <br> Last modified by Diego Nehab on <br>
Wed Oct 3 02:07:59 BRT 2007 Mon Apr 16 21:58:56 HKT 2012
</small> </small>
</p> </p>
</center> </center>

View File

@ -39,24 +39,16 @@ Installation">
<h2>Installation</h2> <h2>Installation</h2>
<p> LuaSocket 2.0.2 uses the new package system for Lua 5.1. <p> LuaSocket 2.1.1-rc still uses Lua&nbsp;5.1's package
All Lua library developers are encouraged to update their libraries so that system. Users that have already made the switch to
all libraries can coexist peacefully and users can benefit from the Lua&nbsp;5.2 should leave the default
standardization and flexibility of the standard. <tt>LUA_COMPAT_MODULE</tt> defined when compiling their Lua
</p> distribution for compatibility with LuaSocket. </p>
<p> <p> Here we describe the standard distribution. If the
Those stuck with Lua 5.0 will need the standard doesn't meet your needs, we refer you to the Lua
<a href=http://www.keplerproject.org/compat/>compat-5.1</a> discussion list, where any question about the package scheme
module. It is maintained by will likely already have been answered. </p>
<a href=http://www.keplerproject.org/>The Kepler
Project</a>'s team, and implements the Lua 5.1 package proposal
on top of Lua 5.0. </p>
<p> Here we will only describe the standard distribution.
If the standard doesn't meet your needs, we refer you to the
Lua discussion list, where any question about the package
scheme will likely already have been answered. </p>
<h3>Directory structure</h3> <h3>Directory structure</h3>
@ -64,14 +56,19 @@ scheme will likely already have been answered. </p>
directories, one for system dependent files, and another for system directories, one for system dependent files, and another for system
independent files. Let's call these directories <tt>&lt;CDIR&gt;</tt> independent files. Let's call these directories <tt>&lt;CDIR&gt;</tt>
and <tt>&lt;LDIR&gt;</tt>, respectively. and <tt>&lt;LDIR&gt;</tt>, respectively.
For instance, in my laptop, I use '<tt>/usr/local/lib/lua/5.0</tt>' for For example, in my laptp, Lua&nbsp;5.1 is configured to
<tt>&lt;CDIR&gt;</tt> and '<tt>/usr/local/share/lua/5.0</tt>' for use '<tt>/usr/local/lib/lua/5.1</tt>' for
<tt>&lt;LDIR&gt;</tt>. On Windows, sometimes only one directory is used, say <tt>&lt;CDIR&gt;</tt> and '<tt>/usr/local/share/lua/5.1</tt>' for
'<tt>c:\program files\lua\5.0</tt>'. Here is the standard LuaSocket <tt>&lt;LDIR&gt;</tt>. On Windows, <tt>&lt;CDIR&gt;</tt>
usually points to the directory where the Lua executable is
found, and <tt>&lt;LDIR&gt;</tt> points to a
<tt>lua/</tt> directory inside <tt>&lt;CDIR&gt;</tt>. (These
settings can be overridden by environment variables
<tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt>. See the Lua
documentation for details.) Here is the standard LuaSocket
distribution directory structure:</p> distribution directory structure:</p>
<pre class=example> <pre class=example>
&lt;LDIR&gt;/compat-5.1.lua
&lt;LDIR&gt;/ltn12.lua &lt;LDIR&gt;/ltn12.lua
&lt;LDIR&gt;/socket.lua &lt;LDIR&gt;/socket.lua
&lt;CDIR&gt;/socket/core.dll &lt;CDIR&gt;/socket/core.dll
@ -88,33 +85,6 @@ distribution directory structure:</p>
would be replaced by <tt>core.so</tt>. would be replaced by <tt>core.so</tt>.
</p> </p>
<p> In order for the interpreter to find all LuaSocket components, three
environment variables need to be set. The first environment variable tells
the interpreter to load the <tt>compat-5.1.lua</tt> module at startup: </p>
<pre class=example>
LUA_INIT=@&lt;LDIR&gt;/compat-5.1.lua
</pre>
<p>
This is only need for Lua&nbsp;5.0! Lua&nbsp;5.1 comes with
the package system built in, of course.
</p>
<p>
The other two environment variables instruct the compatibility module to
look for dynamic libraries and extension modules in the appropriate
directories and with the appropriate filename extensions.
</p>
<pre class=example>
LUA_PATH=&lt;LDIR&gt;/?.lua;?.lua
LUA_CPATH=&lt;CDIR&gt;/?.dll;?.dll
</pre>
<p> Again, naturally, on Unix systems the shared library extension would be
<tt>.so</tt> instead of <tt>.dll</tt>.</p>
<h3>Using LuaSocket</h3> <h3>Using LuaSocket</h3>
<p> With the above setup, and an interpreter with shared library support, <p> With the above setup, and an interpreter with shared library support,
@ -122,19 +92,19 @@ it should be easy to use LuaSocket. Just fire the interpreter and use the
<tt>require</tt> function to gain access to whatever module you need:</p> <tt>require</tt> function to gain access to whatever module you need:</p>
<pre class=example> <pre class=example>
Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
&gt; socket = require("socket") &gt; socket = require("socket")
&gt; print(socket._VERSION) &gt; print(socket._VERSION)
--&gt; LuaSocket 2.0.2 --&gt; LuaSocket 2.1.1-rc1
</pre> </pre>
<p> Each module loads their dependencies automatically, so you only need to <p> Each module loads their dependencies automatically, so you only need to
load the modules you directly depend upon: </p> load the modules you directly depend upon: </p>
<pre class=example> <pre class=example>
Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
&gt; http = require("socket.http") &gt; http = require("socket.http")
&gt; print(http.request("http://www.cs.princeton.edu/~diego/professional/luasocket")) &gt; print(http.request("http://www.impa.br/~diego/software/luasocket"))
--&gt; homepage gets dumped to terminal --&gt; homepage gets dumped to terminal
</pre> </pre>
@ -153,7 +123,7 @@ Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio
<p> <p>
<small> <small>
Last modified by Diego Nehab on <br> Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:30 EDT 2006 Mon Apr 16 21:01:42 HKT 2012
</small> </small>
</p> </p>
</center> </center>

View File

@ -42,6 +42,7 @@ Support, Manual">
<blockquote> <blockquote>
<a href="dns.html">DNS (in socket)</a> <a href="dns.html">DNS (in socket)</a>
<blockquote> <blockquote>
<a href="dns.html#getaddrinfo">getaddrinfo</a>,
<a href="dns.html#gethostname">gethostname</a>, <a href="dns.html#gethostname">gethostname</a>,
<a href="dns.html#tohostname">tohostname</a>, <a href="dns.html#tohostname">tohostname</a>,
<a href="dns.html#toip">toip</a>. <a href="dns.html#toip">toip</a>.
@ -155,9 +156,11 @@ Support, Manual">
<a href="socket.html#sleep">sleep</a>, <a href="socket.html#sleep">sleep</a>,
<a href="socket.html#setsize">_SETSIZE</a>, <a href="socket.html#setsize">_SETSIZE</a>,
<a href="socket.html#source">source</a>, <a href="socket.html#source">source</a>,
<a href="tcp.html#tcp">tcp</a>, <a href="tcp.html#socket.tcp">tcp</a>,
<a href="tcp.html#socket.tcp6">tcp6</a>,
<a href="socket.html#try">try</a>, <a href="socket.html#try">try</a>,
<a href="udp.html#udp">udp</a>, <a href="udp.html#socket.udp">udp</a>,
<a href="udp.html#socket.udp6">udp6</a>,
<a href="socket.html#version">_VERSION</a>. <a href="socket.html#version">_VERSION</a>.
</blockquote> </blockquote>
</blockquote> </blockquote>
@ -194,6 +197,7 @@ Support, Manual">
<a href="udp.html">UDP (in socket)</a> <a href="udp.html">UDP (in socket)</a>
<blockquote> <blockquote>
<a href="udp.html#close">close</a>, <a href="udp.html#close">close</a>,
<a href="udp.html#getoption">getoption</a>,
<a href="udp.html#getpeername">getpeername</a>, <a href="udp.html#getpeername">getpeername</a>,
<a href="udp.html#getsockname">getsockname</a>, <a href="udp.html#getsockname">getsockname</a>,
<a href="udp.html#receive">receive</a>, <a href="udp.html#receive">receive</a>,

View File

@ -36,16 +36,16 @@
<!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2 id=tcp>TCP</h2> <h2 id="tcp">TCP</h2>
<!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=socket.tcp> <p class=name id="socket.tcp">
socket.<b>tcp()</b> socket.<b>tcp()</b>
</p> </p>
<p class=description> <p class=description>
Creates and returns a TCP master object. A master object can Creates and returns an IPv4 TCP master object. A master object can
be transformed into a server object with the method be transformed into a server object with the method
<a href=#listen><tt>listen</tt></a> (after a call to <a <a href=#listen><tt>listen</tt></a> (after a call to <a
href=#bind><tt>bind</tt></a>) or into a client object with href=#bind><tt>bind</tt></a>) or into a client object with
@ -58,9 +58,34 @@ In case of success, a new master object is returned. In case of error,
<b><tt>nil</tt></b> is returned, followed by an error message. <b><tt>nil</tt></b> is returned, followed by an error message.
</p> </p>
<!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id="socket.tcp6">
socket.<b>tcp6()</b>
</p>
<p class=description>
Creates and returns an IPv6 TCP master object. A master object can
be transformed into a server object with the method
<a href=#listen><tt>listen</tt></a> (after a call to <a
href=#bind><tt>bind</tt></a>) or into a client object with
the method <a href=#connect><tt>connect</tt></a>. The only other
method supported by a master object is the
<a href=#close><tt>close</tt></a> method.</p>
<p class=return>
In case of success, a new master object is returned. In case of error,
<b><tt>nil</tt></b> is returned, followed by an error message.
</p>
<p class=note>
Note: The TCP object returned will have the option
"<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>.
</p>
<!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=accept> <p class=name id="accept">
server:<b>accept()</b> server:<b>accept()</b>
</p> </p>
@ -87,7 +112,7 @@ might block until <em>another</em> client shows up.
<!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=bind> <p class=name id="bind">
master:<b>bind(</b>address, port<b>)</b> master:<b>bind(</b>address, port<b>)</b>
</p> </p>
@ -116,7 +141,7 @@ is available and is a shortcut for the creation of server sockets.
<!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=close> <p class=name id="close">
master:<b>close()</b><br> master:<b>close()</b><br>
client:<b>close()</b><br> client:<b>close()</b><br>
server:<b>close()</b> server:<b>close()</b>
@ -139,7 +164,7 @@ automatically closed before destruction, though.
<!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=connect> <p class=name id="connect">
master:<b>connect(</b>address, port<b>)</b> master:<b>connect(</b>address, port<b>)</b>
</p> </p>
@ -180,9 +205,18 @@ href=socket.html#select><tt>socket.select</tt></a> with the socket in the
established. established.
</p> </p>
<p class=note>
Note: Starting with LuaSocket 2.1, the host name resolution
depends on whether the socket was created by <a
href=#socket.tcp><tt>socket.tcp</tt></a> or <a
href=#socket.tcp6><tt>socket.tcp6</tt></a>. Addresses from
the appropriate family are tried in succession until the
first success or until the last failure.
</p>
<!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=getpeername> <p class=name id="getpeername">
client:<b>getpeername()</b> client:<b>getpeername()</b>
</p> </p>
@ -202,7 +236,7 @@ Note: It makes no sense to call this method on server objects.
<!-- getsockname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- getsockname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=getsockname> <p class=name id="getsockname">
master:<b>getsockname()</b><br> master:<b>getsockname()</b><br>
client:<b>getsockname()</b><br> client:<b>getsockname()</b><br>
server:<b>getsockname()</b> server:<b>getsockname()</b>
@ -219,7 +253,7 @@ the port. In case of error, the method returns <b><tt>nil</tt></b>.
<!-- getstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- getstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=getstats> <p class=name id="getstats">
master:<b>getstats()</b><br> master:<b>getstats()</b><br>
client:<b>getstats()</b><br> client:<b>getstats()</b><br>
server:<b>getstats()</b><br> server:<b>getstats()</b><br>
@ -237,7 +271,7 @@ and the age of the socket object in seconds.
<!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=listen> <p class=name id="listen">
master:<b>listen(</b>backlog<b>)</b> master:<b>listen(</b>backlog<b>)</b>
</p> </p>
@ -265,7 +299,7 @@ method returns <b><tt>nil</tt></b> followed by an error message.
<!-- receive ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- receive ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=receive> <p class=name id="receive">
client:<b>receive(</b>[pattern [, prefix]]<b>)</b> client:<b>receive(</b>[pattern [, prefix]]<b>)</b>
</p> </p>
@ -316,7 +350,7 @@ too.
<!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=send> <p class=name id="send">
client:<b>send(</b>data [, i [, j]]<b>)</b> client:<b>send(</b>data [, i [, j]]<b>)</b>
</p> </p>
@ -354,7 +388,7 @@ instead of calling the method several times.
<!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=setoption> <p class=name id="setoption">
client:<b>setoption(</b>option [, value]<b>)</b><br> client:<b>setoption(</b>option [, value]<b>)</b><br>
server:<b>setoption(</b>option [, value]<b>)</b> server:<b>setoption(</b>option [, value]<b>)</b>
</p> </p>
@ -392,8 +426,11 @@ used in validating addresses supplied in a call to
<a href=#bind><tt>bind</tt></a> should allow reuse of local addresses; <a href=#bind><tt>bind</tt></a> should allow reuse of local addresses;
<li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt> <li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt>
disables the Nagle's algorithm for the connection. disables the Nagle's algorithm for the connection;
<li> '<tt>ipv6-v6only</tt>':
Setting this option to <tt>true</tt> restricts an <tt>inet6</tt> socket to
sending and receiving only IPv6 packets.
</ul> </ul>
<p class=return> <p class=return>
@ -407,7 +444,7 @@ Note: The descriptions above come from the man pages.
<!-- getoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- getoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=getoption> <p class=name id="getoption">
client:<b>getoption(</b>option)</b><br> client:<b>getoption(</b>option)</b><br>
server:<b>getoption(</b>option)</b> server:<b>getoption(</b>option)</b>
</p> </p>
@ -433,13 +470,9 @@ The method returns the option <tt>value</tt> in case of success, or
<b><tt>nil</tt></b> followed by an error message otherwise. <b><tt>nil</tt></b> followed by an error message otherwise.
</p> </p>
<p class=note>
Note: The descriptions above come from the man pages.
</p>
<!-- setstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- setstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=setstats> <p class=name id="setstats">
master:<b>setstats(</b>received, sent, age<b>)</b><br> master:<b>setstats(</b>received, sent, age<b>)</b><br>
client:<b>setstats(</b>received, sent, age<b>)</b><br> client:<b>setstats(</b>received, sent, age<b>)</b><br>
server:<b>setstats(</b>received, sent, age<b>)</b><br> server:<b>setstats(</b>received, sent, age<b>)</b><br>
@ -462,7 +495,7 @@ The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise.
<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=settimeout> <p class=name id="settimeout">
master:<b>settimeout(</b>value [, mode]<b>)</b><br> master:<b>settimeout(</b>value [, mode]<b>)</b><br>
client:<b>settimeout(</b>value [, mode]<b>)</b><br> client:<b>settimeout(</b>value [, mode]<b>)</b><br>
server:<b>settimeout(</b>value [, mode]<b>)</b> server:<b>settimeout(</b>value [, mode]<b>)</b>
@ -519,7 +552,7 @@ contained verbs making their imperative nature obvious.
<!-- shutdown +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- shutdown +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=shutdown> <p class=name id="shutdown">
client:<b>shutdown(</b>mode<b>)</b><br> client:<b>shutdown(</b>mode<b>)</b><br>
</p> </p>
@ -543,7 +576,7 @@ This function returns 1.
<!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=dirty> <p class=name id="dirty">
master:<b>dirty()</b><br> master:<b>dirty()</b><br>
client:<b>dirty()</b><br> client:<b>dirty()</b><br>
server:<b>dirty()</b> server:<b>dirty()</b>
@ -563,7 +596,7 @@ Note: <b>This is an internal method, any use is unlikely to be portable.</b>
<!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=getfd> <p class=name id="getfd">
master:<b>getfd()</b><br> master:<b>getfd()</b><br>
client:<b>getfd()</b><br> client:<b>getfd()</b><br>
server:<b>getfd()</b> server:<b>getfd()</b>
@ -583,7 +616,7 @@ Note: <b>This is an internal method, any use is unlikely to be portable.</b>
<!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=setfd> <p class=name id="setfd">
master:<b>setfd(</b>fd<b>)</b><br> master:<b>setfd(</b>fd<b>)</b><br>
client:<b>setfd(</b>fd<b>)</b><br> client:<b>setfd(</b>fd<b>)</b><br>
server:<b>setfd(</b>fd<b>)</b> server:<b>setfd(</b>fd<b>)</b>

View File

@ -37,7 +37,7 @@
<!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2 id=udp>UDP</h2> <h2 id="udp">UDP</h2>
<!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -46,10 +46,12 @@ socket.<b>udp()</b>
</p> </p>
<p class="description"> <p class="description">
Creates and returns an unconnected UDP object. Unconnected objects support the Creates and returns an unconnected IPv4 UDP object.
Unconnected objects support the
<a href="#sendto"><tt>sendto</tt></a>, <a href="#sendto"><tt>sendto</tt></a>,
<a href="#receive"><tt>receive</tt></a>, <a href="#receive"><tt>receive</tt></a>,
<a href="#receivefrom"><tt>receivefrom</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="#getsockname"><tt>getsockname</tt></a>,
<a href="#setoption"><tt>setoption</tt></a>, <a href="#setoption"><tt>setoption</tt></a>,
<a href="#settimeout"><tt>settimeout</tt></a>, <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
an error message. an error message.
</p> </p>
<!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class="name" id="socket.udp6">
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>
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 TCP object returned will have the option
"<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>.
</p>
<!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class="name" id="close"> <p class="name" id="close">
@ -177,6 +217,40 @@ address and port as extra return values (and is therefore slightly less
efficient). efficient).
</p> </p>
<!-- getoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class="name" id="getoption">
connected:<b>getoption()</b><br>
unconnected:<b>getoption()</b>
</p>
<p class="description">
Gets an option value from the UDP object.
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.
<ul>
<li> '<tt>dontroute</tt>'
<li> '<tt>broadcast</tt>'
<li> '<tt>reuseaddr</tt>'
<li> '<tt>reuseport</tt>'
<li> '<tt>ip-multicast-loop</tt>'
<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-drop-membership</tt>'
</ul>
</p>
<p class=return>
The method returns the option <tt>value</tt> in case of
success, or
<b><tt>nil</tt></b> followed by an error message otherwise.
</p>
<!-- send ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- send ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class="name" id="send"> <p class="name" id="send">
@ -284,6 +358,15 @@ is recommended when the same peer is used for several transmissions
and can result in up to 30% performance gains. and can result in up to 30% performance gains.
</p> </p>
<p class=note>
Note: Starting with LuaSocket 2.1, the host name resolution
depends on whether the socket was created by <a
href=#socket.udp><tt>socket.udp</tt></a> or <a
href=#socket.udp6><tt>socket.udp6</tt></a>. Addresses from
the appropriate family are tried in succession until the
first success or until the last failure.
</p>
<!-- setsockname +++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- setsockname +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class="name" id="setsockname"> <p class="name" id="setsockname">
@ -333,12 +416,47 @@ name, and <tt>value</tt> depends on the option being set:
</p> </p>
<ul> <ul>
<li>'<tt>dontroute</tt>': Setting this option to <tt>true</tt> <li> '<tt>dontroute</tt>': Indicates that outgoing
indicates that outgoing messages should bypass the standard routing messages should bypass the standard routing facilities.
facilities;</li> Receives a boolean value;
<li>'<tt>broadcast</tt>': Setting this option to <tt>true</tt> <li> '<tt>broadcast</tt>': Requests permission to send
requests permission to send broadcast datagrams on the broadcast datagrams on the socket.
socket.</li> 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.
Receives a boolean value;
<li> '<tt>reuseport</tt>': Allows completely duplicate
bindings by multiple processes if they all set
'<tt>reuseport</tt>' before binding the port.
Receives a boolean value;
<li> '<tt>ip-multicast-loop</tt>':
Specifies whether or not a copy of an outgoing multicast
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
sending and receiving only IPv6 packets.
Receive a boolean value;
<li> '<tt>ip-multicast-if</tt>':
Sets the interface over which outgoing multicast datagrams
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.
Receives a number;
<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
IP address;
<li> '<tt>ip-drop-membership</tt>': Leaves the multicast
group specified.
Receives a table with fields
<tt>multiaddr</tt> and <tt>interface</tt>, each containing an
IP address.
</ul> </ul>
<p class="return"> <p class="return">
@ -346,9 +464,8 @@ The method returns 1 in case of success, or
<b><tt>nil</tt></b> followed by an error message otherwise. <b><tt>nil</tt></b> followed by an error message otherwise.
</p> </p>
<p class="note"> <p class=note>
Note: The descriptions above come from the man Note: The descriptions above come from the man pages.
pages.
</p> </p>
<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

View File

@ -36,7 +36,7 @@
<!-- url ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- url ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2 id=url>URL</h2> <h2 id="url">URL</h2>
<p> <p>
The <tt>url</tt> namespace provides functions to parse, protect, The <tt>url</tt> namespace provides functions to parse, protect,
@ -69,7 +69,7 @@ An URL is defined by the following grammar:
<!-- absolute +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- absolute +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=absolute> <p class=name id="absolute">
url.<b>absolute(</b>base, relative<b>)</b> url.<b>absolute(</b>base, relative<b>)</b>
</p> </p>
@ -125,7 +125,7 @@ g;x?y#s = http://a/b/c/g;x?y#s
<!-- build ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- build ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=build> <p class=name id="build">
url.<b>build(</b>parsed_url<b>)</b> url.<b>build(</b>parsed_url<b>)</b>
</p> </p>
@ -146,7 +146,7 @@ The function returns a string with the built URL.
<!-- build_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- build_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=build_path> <p class=name id="build_path">
url.<b>build_path(</b>segments, unsafe<b>)</b> url.<b>build_path(</b>segments, unsafe<b>)</b>
</p> </p>
@ -200,7 +200,7 @@ code = url.escape("/#?;")
<!-- parse ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- parse ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=parse> <p class=name id="parse">
url.<b>parse(</b>url, default<b>)</b> url.<b>parse(</b>url, default<b>)</b>
</p> </p>
@ -265,7 +265,7 @@ parsed_url = url.parse("ftp://root:passwd@unsafe.org/pub/virus.exe;type=i")
<!-- parse_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- parse_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=parse_path> <p class=name id="parse_path">
url.<b>parse_path(</b>path<b>)</b> url.<b>parse_path(</b>path<b>)</b>
</p> </p>

View File

@ -1,7 +1,7 @@
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# Distribution makefile # Distribution makefile
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
DIST = luasocket-2.0.3 DIST = luasocket-2.1.1-rc1
TEST = \ TEST = \
test/README \ test/README \

View File

@ -11,8 +11,8 @@
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Current socket library version * Current socket library version
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
#define LUASOCKET_VERSION "LuaSocket 2.1.1" #define LUASOCKET_VERSION "LuaSocket 2.1.1-rc1"
#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2011 Diego Nehab" #define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2012 Diego Nehab"
#define LUASOCKET_AUTHORS "Diego Nehab" #define LUASOCKET_AUTHORS "Diego Nehab"
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\

View File

@ -13,8 +13,8 @@
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Current MIME library version * Current MIME library version
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
#define MIME_VERSION "MIME 1.0.3" #define MIME_VERSION "MIME 1.0.3-rc1"
#define MIME_COPYRIGHT "Copyright (C) 2004-2009 Diego Nehab" #define MIME_COPYRIGHT "Copyright (C) 2004-2012 Diego Nehab"
#define MIME_AUTHORS "Diego Nehab" #define MIME_AUTHORS "Diego Nehab"
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\