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 | |
| 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
| -rw-r--r-- | TODO | 79 | ||||
| -rw-r--r-- | doc/dns.html | 61 | ||||
| -rw-r--r-- | doc/http.html | 8 | ||||
| -rw-r--r-- | doc/index.html | 80 | ||||
| -rw-r--r-- | doc/installation.html | 78 | ||||
| -rw-r--r-- | doc/reference.html | 8 | ||||
| -rw-r--r-- | doc/tcp.html | 85 | ||||
| -rw-r--r-- | doc/udp.html | 143 | ||||
| -rw-r--r-- | doc/url.html | 12 | ||||
| -rw-r--r-- | makefile.dist | 2 | ||||
| -rw-r--r-- | src/luasocket.h | 4 | ||||
| -rw-r--r-- | src/mime.h | 4 |
12 files changed, 367 insertions, 197 deletions
| @@ -1,38 +1,47 @@ | |||
| 1 | - merge luaL_typeerror into auxiliar to avoid using luaL prefix? | 1 | - merge luaL_typeerror into auxiliar to avoid using luaL prefix? |
| 2 | - document ipv5_v6only default option being set? | 2 | - getsockname should also support IPv6, no? |
| 3 | - document bind and connect behavior based on address? | 3 | - remove RCSID from files? |
| 4 | - document tcp6 and udp6 | 4 | - shouldn't we instead make the code compatible to Lua 5.2 |
| 5 | - document dns.getaddrinfo | 5 | without any compat stuff, and use a compatibility layer to |
| 6 | - check getaddrinfo's output format | 6 | make it work on 5.1? |
| 7 | - add functionality to query if object is ipv4 or 6? | 7 | - why 2.1.1 rather than 2.1? |
| 8 | - normalize error messages to have all first capitals or not? | 8 | - add what's new to manual |
| 9 | - what is this lua_Reg vs lua_reg business? | 9 | - should there be an equivalent to tohostname for IPv6? |
| 10 | what is this putchar vs addchar business? | 10 | - should we add service name resolution as well to |
| 11 | is this the compat-5.2 stuff? | 11 | getaddrinfo? |
| 12 | - why 2.1.1 rather than 2.1? | 12 | - document bind and connect behavior based on address? |
| 13 | - update copyright date everywhere? | 13 | |
| 14 | - what to do about author? | 14 | - add functionality to query if object is ipv4 or 6? |
| 15 | - any chance we can do without the compat for the final release? | 15 | - update copyright date everywhere? |
| 16 | - are only _API symbols being exported now? | 16 | - what to do about author? |
| 17 | it used to export all externs... | 17 | - add http POST sample to manual |
| 18 | - document zero-sized send on udp vs. tcp? | 18 | people keep asking stupid questions |
| 19 | - add http POST sample to manual | 19 | - documentation of dirty/getfd/setfd is problematic because of portability |
| 20 | people keep asking stupid questions | 20 | same for unix and serial. |
| 21 | - document unix socket and serial socket? add raw support? | 21 | what to do about this? add a stronger disclaimer? |
| 22 | if so, add tests? | 22 | - remove references to Lua 5.0 from documentation, add 5.2? |
| 23 | - make sure unix conforms to tcp and udp style | 23 | - update lua and luasocket version in samples in documentation |
| 24 | - make sure serial conforms to tcp and udp style | 24 | - document headers.lua? |
| 25 | does it need to use write/read instead of send/receive? | 25 | - fix makefile with decent defaults? |
| 26 | - documentation of dirty/getfd/setfd is problematic because of portability | 26 | |
| 27 | same for unix and serial. | 27 | Done: |
| 28 | what to do about this? add a stronger disclaimer? | 28 | |
| 29 | - nice getoption! | 29 | - document ipv5_v6only default option being set? |
| 30 | prefix all setters with set_ and all getters with get_? | 30 | - document tcp6 and udp6 |
| 31 | - add what's new to manual | 31 | - document dns.getaddrinfo |
| 32 | - remove references to Lua 5.0 from documentation, add 5.2? | 32 | - document zero-sized send on udp vs. tcp? |
| 33 | - update lua and luasocket version in samples in documentation | 33 | no. |
| 34 | - document headers.lua? | 34 | - document unix socket and serial socket? add raw support? |
| 35 | - fix makefile with decent defaults? | 35 | no. |
| 36 | - document getoption | ||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | |||
| 36 | 45 | ||
| 37 | 46 | ||
| 38 | replace \r\n with \0xD\0xA in everything | 47 | replace \r\n with \0xD\0xA in everything |
diff --git a/doc/dns.html b/doc/dns.html index a38e368..c4a0472 100644 --- a/doc/dns.html +++ b/doc/dns.html | |||
| @@ -39,12 +39,16 @@ | |||
| 39 | <h2 id=dns>DNS</h2> | 39 | <h2 id=dns>DNS</h2> |
| 40 | 40 | ||
| 41 | <p> | 41 | <p> |
| 42 | Name resolution functions return <em>all</em> information obtained from the | 42 | IPv4 name resolution functions |
| 43 | resolver in a table of the form: | 43 | <a href=#toip><tt>dns.toip</tt></a> |
| 44 | and | ||
| 45 | <a href=#tohostname><tt>dns.tohostname</tt></a> | ||
| 46 | return <em>all</em> information obtained from | ||
| 47 | the resolver in a table of the form: | ||
| 44 | </p> | 48 | </p> |
| 45 | 49 | ||
| 46 | <blockquote><tt> | 50 | <blockquote><tt> |
| 47 | resolved = {<br> | 51 | resolved4 = {<br> |
| 48 | name = <i>canonic-name</i>,<br> | 52 | name = <i>canonic-name</i>,<br> |
| 49 | alias = <i>alias-list</i>,<br> | 53 | alias = <i>alias-list</i>,<br> |
| 50 | ip = <i>ip-address-list</i><br> | 54 | ip = <i>ip-address-list</i><br> |
| @@ -55,6 +59,53 @@ resolved = {<br> | |||
| 55 | Note that the <tt>alias</tt> list can be empty. | 59 | Note that the <tt>alias</tt> list can be empty. |
| 56 | </p> | 60 | </p> |
| 57 | 61 | ||
| 62 | <p> | ||
| 63 | The more general name resolution function | ||
| 64 | <a href=#getaddrinfo><tt>dns.getaddrinfo</tt></a>, which | ||
| 65 | supports both IPv6 and IPv4, | ||
| 66 | returns <em>all</em> information obtained from | ||
| 67 | the resolver in a table of the form: | ||
| 68 | </p> | ||
| 69 | |||
| 70 | <blockquote><tt> | ||
| 71 | resolved6 = {<br> | ||
| 72 | [1] = {<br> | ||
| 73 | family = <i>family-name-1</i>,<br> | ||
| 74 | addr = <i>address-1</i><br> | ||
| 75 | },<br> | ||
| 76 | ...<br> | ||
| 77 | [n] = {<br> | ||
| 78 | family = <i>family-name-n</i>,<br> | ||
| 79 | addr = <i>address-n</i><br> | ||
| 80 | }<br> | ||
| 81 | } | ||
| 82 | </tt> </blockquote> | ||
| 83 | |||
| 84 | <p> | ||
| 85 | Here, <tt>family</tt> contains the string <tt>"inet"</tt> for IPv4 | ||
| 86 | addresses, and <tt>"inet6"</tt> for IPv6 addresses. | ||
| 87 | </p> | ||
| 88 | |||
| 89 | <!-- getaddrinfo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 90 | |||
| 91 | <p class=name id=getaddrinfo> | ||
| 92 | socket.dns.<b>getaddrinfo(</b>address<b>)</b> | ||
| 93 | </p> | ||
| 94 | |||
| 95 | <p class=description> | ||
| 96 | Converts from host name to address. | ||
| 97 | </p> | ||
| 98 | |||
| 99 | <p class=parameters> | ||
| 100 | <tt>Address</tt> can be an IPv4 or IPv6 address or host name. | ||
| 101 | </p> | ||
| 102 | |||
| 103 | <p class=return> | ||
| 104 | The function returns a table with all information returned by | ||
| 105 | the resolver. In case of error, the function returns <b><tt>nil</tt></b> | ||
| 106 | followed by an error message. | ||
| 107 | </p> | ||
| 108 | |||
| 58 | <!-- gethostname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 109 | <!-- gethostname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 59 | 110 | ||
| 60 | <p class=name id=gethostname> | 111 | <p class=name id=gethostname> |
| @@ -72,7 +123,7 @@ socket.dns.<b>tohostname(</b>address<b>)</b> | |||
| 72 | </p> | 123 | </p> |
| 73 | 124 | ||
| 74 | <p class=description> | 125 | <p class=description> |
| 75 | Converts from IP address to host name. | 126 | Converts from IPv4 address to host name. |
| 76 | </p> | 127 | </p> |
| 77 | 128 | ||
| 78 | <p class=parameters> | 129 | <p class=parameters> |
| @@ -93,7 +144,7 @@ socket.dns.<b>toip(</b>address<b>)</b> | |||
| 93 | </p> | 144 | </p> |
| 94 | 145 | ||
| 95 | <p class=description> | 146 | <p class=description> |
| 96 | Converts from host name to IP address. | 147 | Converts from host name to IPv4 address. |
| 97 | </p> | 148 | </p> |
| 98 | 149 | ||
| 99 | <p class=parameters> | 150 | <p class=parameters> |
diff --git a/doc/http.html b/doc/http.html index 66282a4..9f3f087 100644 --- a/doc/http.html +++ b/doc/http.html | |||
| @@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | <!-- http +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 37 | <!-- http +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 38 | 38 | ||
| 39 | <h2 id=http>HTTP</h2> | 39 | <h2 id="http">HTTP</h2> |
| 40 | 40 | ||
| 41 | <p> | 41 | <p> |
| 42 | HTTP (Hyper Text Transfer Protocol) is the protocol used to exchange | 42 | HTTP (Hyper Text Transfer Protocol) is the protocol used to exchange |
| @@ -119,7 +119,7 @@ the HTTP module: | |||
| 119 | 119 | ||
| 120 | <!-- http.request ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 120 | <!-- http.request ++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 121 | 121 | ||
| 122 | <p class=name id=request> | 122 | <p class=name id="request"> |
| 123 | http.<b>request(</b>url [, body]<b>)</b><br> | 123 | http.<b>request(</b>url [, body]<b>)</b><br> |
| 124 | http.<b>request{</b><br> | 124 | http.<b>request{</b><br> |
| 125 | url = <i>string</i>,<br> | 125 | url = <i>string</i>,<br> |
| @@ -256,7 +256,7 @@ r, c, h = http.request { | |||
| 256 | -- } | 256 | -- } |
| 257 | </pre> | 257 | </pre> |
| 258 | 258 | ||
| 259 | <p class=note id=post> | 259 | <p class=note id="post"> |
| 260 | Note: When sending a POST request, simple interface adds a | 260 | Note: When sending a POST request, simple interface adds a |
| 261 | "<tt>Content-type: application/x-www-form-urlencoded</tt>" | 261 | "<tt>Content-type: application/x-www-form-urlencoded</tt>" |
| 262 | header to the request. This is the type used by | 262 | header to the request. This is the type used by |
| @@ -264,7 +264,7 @@ HTML forms. If you need another type, use the generic | |||
| 264 | interface. | 264 | interface. |
| 265 | </p> | 265 | </p> |
| 266 | 266 | ||
| 267 | <p class=note id=authentication> | 267 | <p class=note id="authentication"> |
| 268 | Note: Some URLs are protected by their | 268 | Note: Some URLs are protected by their |
| 269 | servers from anonymous download. For those URLs, the server must receive | 269 | servers from anonymous download. For those URLs, the server must receive |
| 270 | some sort of authentication along with the request or it will deny | 270 | some sort of authentication along with the request or it will deny |
diff --git a/doc/index.html b/doc/index.html index 665b97b..9da0f3c 100644 --- a/doc/index.html +++ b/doc/index.html | |||
| @@ -78,8 +78,8 @@ LuaSocket. | |||
| 78 | </p> | 78 | </p> |
| 79 | 79 | ||
| 80 | <p> | 80 | <p> |
| 81 | Copyright © 2004-2007 Diego Nehab. All rights reserved. <br> | 81 | Copyright © 1999-2012 Diego Nehab. All rights reserved. <br> |
| 82 | Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a> | 82 | Author: <A href="http://www.impa.br/~diego">Diego Nehab</a> |
| 83 | </p> | 83 | </p> |
| 84 | 84 | ||
| 85 | <!-- download +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 85 | <!-- download +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -87,25 +87,18 @@ Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a> | |||
| 87 | <h2 id=download>Download</h2> | 87 | <h2 id=download>Download</h2> |
| 88 | 88 | ||
| 89 | <p> | 89 | <p> |
| 90 | LuaSocket version 2.0.3 is now available for download! It is | 90 | LuaSocket version 2.1.1-rc1 is now available for download! |
| 91 | compatible with Lua 5.1, and has | 91 | It is compatible with Lua 5.1 and 5.2, and has |
| 92 | been tested on Windows XP, Linux, and Mac OS X. Chances | 92 | been tested on Windows XP, Linux, and Mac OS X. Chances |
| 93 | are it works well on most UNIX distributions and Windows flavors. | 93 | are it works well on most UNIX distributions and Windows flavors. |
| 94 | </p> | 94 | </p> |
| 95 | 95 | ||
| 96 | <p> | 96 | <p> |
| 97 | The library can be downloaded in source code from the | 97 | The library can be downloaded in source code from the |
| 98 | <a href=http://luaforge.net/projects/luasocket/>LuaSocket | 98 | <a href="https://github.com/diegonehab/luasocket/downloads">LuaSocket |
| 99 | project page</a> at LuaForge. | 99 | project page</a> at GitHub. Besides the full C and Lua source code |
| 100 | Besides the full C and Lua source code for the library, the distribution | 100 | for the library, the distribution contains several examples, |
| 101 | contains several examples, this user's manual and basic test procedures. | 101 | this user's manual and basic test procedures. |
| 102 | </p> | ||
| 103 | |||
| 104 | <p> | ||
| 105 | Danilo Tuler is maintaining Win32 binaries for LuaSocket, which are also | ||
| 106 | available from LuaForge. These are compatible with the | ||
| 107 | <a href=http://luaforge.net/projects/luabinaries>LuaBinaries</a>, | ||
| 108 | also available from LuaForge. | ||
| 109 | </p> | 102 | </p> |
| 110 | 103 | ||
| 111 | <p> Take a look at the <a | 104 | <p> Take a look at the <a |
| @@ -118,15 +111,13 @@ manual to find out how to properly install the library. | |||
| 118 | <h2 id=thanks>Special thanks</h2> | 111 | <h2 id=thanks>Special thanks</h2> |
| 119 | 112 | ||
| 120 | <p> | 113 | <p> |
| 121 | Throughout LuaSocket's history, many people gave suggestions | 114 | This marks the first release of LuaSocket that |
| 122 | that helped improve it. For that, I thank the Lua community. | 115 | wholeheartedly embraces the open-source development |
| 123 | Special thanks go to David Burgess, who has helped push the | 116 | philosophy. After a long hiatus, Matthew Wild finally |
| 124 | library to a new level of quality and from whom I have | 117 | convinced me it was time for a release including IPv6 |
| 125 | learned a lot of stuff that doesn't show up in RFCs. | 118 | and Lua 5.2 support. Special thanks to Sam Roberts, Florian |
| 126 | Special thanks also to Carlos Cassino, who played a big part | 119 | Zeitz, and Paul Aurich, Liam Devine, and everybody else that |
| 127 | in the extensible design seen in the C core of LuaSocket | 120 | has helped bring this library back to life. |
| 128 | 2.0. Mike Pall has been helping a lot too! Thanks to you | ||
| 129 | all! | ||
| 130 | </p> | 121 | </p> |
| 131 | 122 | ||
| 132 | <!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 123 | <!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -134,30 +125,25 @@ all! | |||
| 134 | <h2 id=new>What's New</h2> | 125 | <h2 id=new>What's New</h2> |
| 135 | 126 | ||
| 136 | <p> | 127 | <p> |
| 137 | 2.0.3 is just a bug-fix/update release. | 128 | Main changes for LuaSocket 2.1.1-rc1 are IPv6 support |
| 129 | and Lua 5.2 compatibility. | ||
| 138 | </p> | 130 | </p> |
| 139 | 131 | ||
| 140 | <ul> | 132 | <ul> |
| 141 | <li> Fixed: manual sample of HTTP authentication now uses correct | 133 | <li> Added: Compatible with Lua 5.2 (using <tt>LUA_COMPAT_MODULE</tt>); |
| 142 | "authorization" header (Alexandre Ittner); | 134 | <li> Added: IPv6 support; |
| 143 | <li> Fixed: receive() returns immediatelly if prefix can satisfy | 135 | <ul> |
| 144 | bytes requested (M Joonas Pihlaja); | 136 | <li> <tt>Socket.connect</tt> and <tt>socket.bind</tt> support IPv6 addresses; |
| 145 | <li> Fixed: multicast didn't work on Windows, or anywhere | 137 | <li> <tt>Getpeername</tt> and <tt>getsockname</tt> support IPv6 addresses; |
| 146 | else for that matter (Herbert Leuwer, Adrian Sietsma); | 138 | <li> New <tt>socket.tcp6</tt> and <tt>socket.udp6</tt> functions; |
| 147 | <li> Fixed: select() now reports an error when called with more | 139 | <li> New <tt>socket.dns.getaddrinfo</tt> function; |
| 148 | sockets than FD_SETSIZE (Lorenzo Leonini); | 140 | </ul> |
| 149 | <li> Fixed: manual links to home.html changed to index.html (Robert Hahn); | 141 | <li> Added: <tt>getoption</tt> method; |
| 150 | <li> Fixed: mime.unb64() would return an empty string on results that started | 142 | <li> Fixed: <tt>url.unescape</tt> was returning additional values; |
| 151 | with a null character (Robert Raschke); | 143 | <li> Fixed: Receiving zero-length datagram is now possible; |
| 152 | <li> Fixed: HTTP now automatically redirects on 303 and 307 (Jonathan Gray); | 144 | <li> Improved: Hidden all internal library symbols; |
| 153 | <li> Fixed: calling sleep() with negative numbers could | 145 | <li> Improved: Better error messages; |
| 154 | block forever, wasting CPU. Now it returns immediately (MPB); | 146 | <li> Improved: Better documentation of socket options. |
| 155 | <li> Improved: FTP commands are now sent in upper case to | ||
| 156 | help buggy servers (Anders Eurenius); | ||
| 157 | <li> Improved: known headers now sent in canonic | ||
| 158 | capitalization to help buggy servers (Joseph Stewart); | ||
| 159 | <li> Improved: Clarified tcp:receive() in the manual (MPB); | ||
| 160 | <li> Improved: Decent makefiles (LHF). | ||
| 161 | </ul> | 147 | </ul> |
| 162 | 148 | ||
| 163 | <!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 149 | <!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -166,7 +152,7 @@ all! | |||
| 166 | 152 | ||
| 167 | <p> | 153 | <p> |
| 168 | All previous versions of the LuaSocket library can be downloaded <a | 154 | All previous versions of the LuaSocket library can be downloaded <a |
| 169 | href="http://www.cs.princeton.edu/~diego/professional/luasocket/old"> | 155 | href="http://www.impa.br/~diego/software/luasocket/old"> |
| 170 | here</a>. Although these versions are no longer supported, they are | 156 | here</a>. Although these versions are no longer supported, they are |
| 171 | still available for those that have compatibility issues. | 157 | still available for those that have compatibility issues. |
| 172 | </p> | 158 | </p> |
| @@ -185,7 +171,7 @@ still available for those that have compatibility issues. | |||
| 185 | <p> | 171 | <p> |
| 186 | <small> | 172 | <small> |
| 187 | Last modified by Diego Nehab on <br> | 173 | Last modified by Diego Nehab on <br> |
| 188 | Wed Oct 3 02:07:59 BRT 2007 | 174 | Mon Apr 16 21:58:56 HKT 2012 |
| 189 | </small> | 175 | </small> |
| 190 | </p> | 176 | </p> |
| 191 | </center> | 177 | </center> |
diff --git a/doc/installation.html b/doc/installation.html index bb9a5bb..00b2db0 100644 --- a/doc/installation.html +++ b/doc/installation.html | |||
| @@ -39,24 +39,16 @@ Installation"> | |||
| 39 | 39 | ||
| 40 | <h2>Installation</h2> | 40 | <h2>Installation</h2> |
| 41 | 41 | ||
| 42 | <p> LuaSocket 2.0.2 uses the new package system for Lua 5.1. | 42 | <p> LuaSocket 2.1.1-rc still uses Lua 5.1's package |
| 43 | All Lua library developers are encouraged to update their libraries so that | 43 | system. Users that have already made the switch to |
| 44 | all libraries can coexist peacefully and users can benefit from the | 44 | Lua 5.2 should leave the default |
| 45 | standardization and flexibility of the standard. | 45 | <tt>LUA_COMPAT_MODULE</tt> defined when compiling their Lua |
| 46 | </p> | 46 | distribution for compatibility with LuaSocket. </p> |
| 47 | |||
| 48 | <p> | ||
| 49 | Those stuck with Lua 5.0 will need the | ||
| 50 | <a href=http://www.keplerproject.org/compat/>compat-5.1</a> | ||
| 51 | module. It is maintained by | ||
| 52 | <a href=http://www.keplerproject.org/>The Kepler | ||
| 53 | Project</a>'s team, and implements the Lua 5.1 package proposal | ||
| 54 | on top of Lua 5.0. </p> | ||
| 55 | 47 | ||
| 56 | <p> Here we will only describe the standard distribution. | 48 | <p> Here we describe the standard distribution. If the |
| 57 | If the standard doesn't meet your needs, we refer you to the | 49 | standard doesn't meet your needs, we refer you to the Lua |
| 58 | Lua discussion list, where any question about the package | 50 | discussion list, where any question about the package scheme |
| 59 | scheme will likely already have been answered. </p> | 51 | will likely already have been answered. </p> |
| 60 | 52 | ||
| 61 | <h3>Directory structure</h3> | 53 | <h3>Directory structure</h3> |
| 62 | 54 | ||
| @@ -64,14 +56,19 @@ scheme will likely already have been answered. </p> | |||
| 64 | directories, one for system dependent files, and another for system | 56 | directories, one for system dependent files, and another for system |
| 65 | independent files. Let's call these directories <tt><CDIR></tt> | 57 | independent files. Let's call these directories <tt><CDIR></tt> |
| 66 | and <tt><LDIR></tt>, respectively. | 58 | and <tt><LDIR></tt>, respectively. |
| 67 | For instance, in my laptop, I use '<tt>/usr/local/lib/lua/5.0</tt>' for | 59 | For example, in my laptp, Lua 5.1 is configured to |
| 68 | <tt><CDIR></tt> and '<tt>/usr/local/share/lua/5.0</tt>' for | 60 | use '<tt>/usr/local/lib/lua/5.1</tt>' for |
| 69 | <tt><LDIR></tt>. On Windows, sometimes only one directory is used, say | 61 | <tt><CDIR></tt> and '<tt>/usr/local/share/lua/5.1</tt>' for |
| 70 | '<tt>c:\program files\lua\5.0</tt>'. Here is the standard LuaSocket | 62 | <tt><LDIR></tt>. On Windows, <tt><CDIR></tt> |
| 63 | usually points to the directory where the Lua executable is | ||
| 64 | found, and <tt><LDIR></tt> points to a | ||
| 65 | <tt>lua/</tt> directory inside <tt><CDIR></tt>. (These | ||
| 66 | settings can be overridden by environment variables | ||
| 67 | <tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt>. See the Lua | ||
| 68 | documentation for details.) Here is the standard LuaSocket | ||
| 71 | distribution directory structure:</p> | 69 | distribution directory structure:</p> |
| 72 | 70 | ||
| 73 | <pre class=example> | 71 | <pre class=example> |
| 74 | <LDIR>/compat-5.1.lua | ||
| 75 | <LDIR>/ltn12.lua | 72 | <LDIR>/ltn12.lua |
| 76 | <LDIR>/socket.lua | 73 | <LDIR>/socket.lua |
| 77 | <CDIR>/socket/core.dll | 74 | <CDIR>/socket/core.dll |
| @@ -88,33 +85,6 @@ distribution directory structure:</p> | |||
| 88 | would be replaced by <tt>core.so</tt>. | 85 | would be replaced by <tt>core.so</tt>. |
| 89 | </p> | 86 | </p> |
| 90 | 87 | ||
| 91 | <p> In order for the interpreter to find all LuaSocket components, three | ||
| 92 | environment variables need to be set. The first environment variable tells | ||
| 93 | the interpreter to load the <tt>compat-5.1.lua</tt> module at startup: </p> | ||
| 94 | |||
| 95 | <pre class=example> | ||
| 96 | LUA_INIT=@<LDIR>/compat-5.1.lua | ||
| 97 | </pre> | ||
| 98 | |||
| 99 | <p> | ||
| 100 | This is only need for Lua 5.0! Lua 5.1 comes with | ||
| 101 | the package system built in, of course. | ||
| 102 | </p> | ||
| 103 | |||
| 104 | <p> | ||
| 105 | The other two environment variables instruct the compatibility module to | ||
| 106 | look for dynamic libraries and extension modules in the appropriate | ||
| 107 | directories and with the appropriate filename extensions. | ||
| 108 | </p> | ||
| 109 | |||
| 110 | <pre class=example> | ||
| 111 | LUA_PATH=<LDIR>/?.lua;?.lua | ||
| 112 | LUA_CPATH=<CDIR>/?.dll;?.dll | ||
| 113 | </pre> | ||
| 114 | |||
| 115 | <p> Again, naturally, on Unix systems the shared library extension would be | ||
| 116 | <tt>.so</tt> instead of <tt>.dll</tt>.</p> | ||
| 117 | |||
| 118 | <h3>Using LuaSocket</h3> | 88 | <h3>Using LuaSocket</h3> |
| 119 | 89 | ||
| 120 | <p> With the above setup, and an interpreter with shared library support, | 90 | <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 | |||
| 122 | <tt>require</tt> function to gain access to whatever module you need:</p> | 92 | <tt>require</tt> function to gain access to whatever module you need:</p> |
| 123 | 93 | ||
| 124 | <pre class=example> | 94 | <pre class=example> |
| 125 | Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio | 95 | Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio |
| 126 | > socket = require("socket") | 96 | > socket = require("socket") |
| 127 | > print(socket._VERSION) | 97 | > print(socket._VERSION) |
| 128 | --> LuaSocket 2.0.2 | 98 | --> LuaSocket 2.1.1-rc1 |
| 129 | </pre> | 99 | </pre> |
| 130 | 100 | ||
| 131 | <p> Each module loads their dependencies automatically, so you only need to | 101 | <p> Each module loads their dependencies automatically, so you only need to |
| 132 | load the modules you directly depend upon: </p> | 102 | load the modules you directly depend upon: </p> |
| 133 | 103 | ||
| 134 | <pre class=example> | 104 | <pre class=example> |
| 135 | Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio | 105 | Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio |
| 136 | > http = require("socket.http") | 106 | > http = require("socket.http") |
| 137 | > print(http.request("http://www.cs.princeton.edu/~diego/professional/luasocket")) | 107 | > print(http.request("http://www.impa.br/~diego/software/luasocket")) |
| 138 | --> homepage gets dumped to terminal | 108 | --> homepage gets dumped to terminal |
| 139 | </pre> | 109 | </pre> |
| 140 | 110 | ||
| @@ -153,7 +123,7 @@ Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio | |||
| 153 | <p> | 123 | <p> |
| 154 | <small> | 124 | <small> |
| 155 | Last modified by Diego Nehab on <br> | 125 | Last modified by Diego Nehab on <br> |
| 156 | Thu Apr 20 00:25:30 EDT 2006 | 126 | Mon Apr 16 21:01:42 HKT 2012 |
| 157 | </small> | 127 | </small> |
| 158 | </p> | 128 | </p> |
| 159 | </center> | 129 | </center> |
diff --git a/doc/reference.html b/doc/reference.html index 8da3956..d1043d4 100644 --- a/doc/reference.html +++ b/doc/reference.html | |||
| @@ -42,6 +42,7 @@ Support, Manual"> | |||
| 42 | <blockquote> | 42 | <blockquote> |
| 43 | <a href="dns.html">DNS (in socket)</a> | 43 | <a href="dns.html">DNS (in socket)</a> |
| 44 | <blockquote> | 44 | <blockquote> |
| 45 | <a href="dns.html#getaddrinfo">getaddrinfo</a>, | ||
| 45 | <a href="dns.html#gethostname">gethostname</a>, | 46 | <a href="dns.html#gethostname">gethostname</a>, |
| 46 | <a href="dns.html#tohostname">tohostname</a>, | 47 | <a href="dns.html#tohostname">tohostname</a>, |
| 47 | <a href="dns.html#toip">toip</a>. | 48 | <a href="dns.html#toip">toip</a>. |
| @@ -155,9 +156,11 @@ Support, Manual"> | |||
| 155 | <a href="socket.html#sleep">sleep</a>, | 156 | <a href="socket.html#sleep">sleep</a>, |
| 156 | <a href="socket.html#setsize">_SETSIZE</a>, | 157 | <a href="socket.html#setsize">_SETSIZE</a>, |
| 157 | <a href="socket.html#source">source</a>, | 158 | <a href="socket.html#source">source</a>, |
| 158 | <a href="tcp.html#tcp">tcp</a>, | 159 | <a href="tcp.html#socket.tcp">tcp</a>, |
| 160 | <a href="tcp.html#socket.tcp6">tcp6</a>, | ||
| 159 | <a href="socket.html#try">try</a>, | 161 | <a href="socket.html#try">try</a>, |
| 160 | <a href="udp.html#udp">udp</a>, | 162 | <a href="udp.html#socket.udp">udp</a>, |
| 163 | <a href="udp.html#socket.udp6">udp6</a>, | ||
| 161 | <a href="socket.html#version">_VERSION</a>. | 164 | <a href="socket.html#version">_VERSION</a>. |
| 162 | </blockquote> | 165 | </blockquote> |
| 163 | </blockquote> | 166 | </blockquote> |
| @@ -194,6 +197,7 @@ Support, Manual"> | |||
| 194 | <a href="udp.html">UDP (in socket)</a> | 197 | <a href="udp.html">UDP (in socket)</a> |
| 195 | <blockquote> | 198 | <blockquote> |
| 196 | <a href="udp.html#close">close</a>, | 199 | <a href="udp.html#close">close</a>, |
| 200 | <a href="udp.html#getoption">getoption</a>, | ||
| 197 | <a href="udp.html#getpeername">getpeername</a>, | 201 | <a href="udp.html#getpeername">getpeername</a>, |
| 198 | <a href="udp.html#getsockname">getsockname</a>, | 202 | <a href="udp.html#getsockname">getsockname</a>, |
| 199 | <a href="udp.html#receive">receive</a>, | 203 | <a href="udp.html#receive">receive</a>, |
diff --git a/doc/tcp.html b/doc/tcp.html index f59d7ac..dc1a0b6 100644 --- a/doc/tcp.html +++ b/doc/tcp.html | |||
| @@ -36,16 +36,16 @@ | |||
| 36 | 36 | ||
| 37 | <!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 37 | <!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 38 | 38 | ||
| 39 | <h2 id=tcp>TCP</h2> | 39 | <h2 id="tcp">TCP</h2> |
| 40 | 40 | ||
| 41 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 41 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 42 | 42 | ||
| 43 | <p class=name id=socket.tcp> | 43 | <p class=name id="socket.tcp"> |
| 44 | socket.<b>tcp()</b> | 44 | socket.<b>tcp()</b> |
| 45 | </p> | 45 | </p> |
| 46 | 46 | ||
| 47 | <p class=description> | 47 | <p class=description> |
| 48 | Creates and returns a TCP master object. A master object can | 48 | Creates and returns an IPv4 TCP master object. A master object can |
| 49 | be transformed into a server object with the method | 49 | be transformed into a server object with the method |
| 50 | <a href=#listen><tt>listen</tt></a> (after a call to <a | 50 | <a href=#listen><tt>listen</tt></a> (after a call to <a |
| 51 | href=#bind><tt>bind</tt></a>) or into a client object with | 51 | 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, | |||
| 58 | <b><tt>nil</tt></b> is returned, followed by an error message. | 58 | <b><tt>nil</tt></b> is returned, followed by an error message. |
| 59 | </p> | 59 | </p> |
| 60 | 60 | ||
| 61 | <!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 62 | |||
| 63 | <p class=name id="socket.tcp6"> | ||
| 64 | socket.<b>tcp6()</b> | ||
| 65 | </p> | ||
| 66 | |||
| 67 | <p class=description> | ||
| 68 | Creates and returns an IPv6 TCP master object. A master object can | ||
| 69 | be transformed into a server object with the method | ||
| 70 | <a href=#listen><tt>listen</tt></a> (after a call to <a | ||
| 71 | href=#bind><tt>bind</tt></a>) or into a client object with | ||
| 72 | the method <a href=#connect><tt>connect</tt></a>. The only other | ||
| 73 | method supported by a master object is the | ||
| 74 | <a href=#close><tt>close</tt></a> method.</p> | ||
| 75 | |||
| 76 | <p class=return> | ||
| 77 | In case of success, a new master object is returned. In case of error, | ||
| 78 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
| 79 | </p> | ||
| 80 | |||
| 81 | <p class=note> | ||
| 82 | Note: The TCP object returned will have the option | ||
| 83 | "<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>. | ||
| 84 | </p> | ||
| 85 | |||
| 61 | <!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 86 | <!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 62 | 87 | ||
| 63 | <p class=name id=accept> | 88 | <p class=name id="accept"> |
| 64 | server:<b>accept()</b> | 89 | server:<b>accept()</b> |
| 65 | </p> | 90 | </p> |
| 66 | 91 | ||
| @@ -87,7 +112,7 @@ might block until <em>another</em> client shows up. | |||
| 87 | 112 | ||
| 88 | <!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 113 | <!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 89 | 114 | ||
| 90 | <p class=name id=bind> | 115 | <p class=name id="bind"> |
| 91 | master:<b>bind(</b>address, port<b>)</b> | 116 | master:<b>bind(</b>address, port<b>)</b> |
| 92 | </p> | 117 | </p> |
| 93 | 118 | ||
| @@ -116,7 +141,7 @@ is available and is a shortcut for the creation of server sockets. | |||
| 116 | 141 | ||
| 117 | <!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 142 | <!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 118 | 143 | ||
| 119 | <p class=name id=close> | 144 | <p class=name id="close"> |
| 120 | master:<b>close()</b><br> | 145 | master:<b>close()</b><br> |
| 121 | client:<b>close()</b><br> | 146 | client:<b>close()</b><br> |
| 122 | server:<b>close()</b> | 147 | server:<b>close()</b> |
| @@ -139,7 +164,7 @@ automatically closed before destruction, though. | |||
| 139 | 164 | ||
| 140 | <!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 165 | <!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 141 | 166 | ||
| 142 | <p class=name id=connect> | 167 | <p class=name id="connect"> |
| 143 | master:<b>connect(</b>address, port<b>)</b> | 168 | master:<b>connect(</b>address, port<b>)</b> |
| 144 | </p> | 169 | </p> |
| 145 | 170 | ||
| @@ -180,9 +205,18 @@ href=socket.html#select><tt>socket.select</tt></a> with the socket in the | |||
| 180 | established. | 205 | established. |
| 181 | </p> | 206 | </p> |
| 182 | 207 | ||
| 208 | <p class=note> | ||
| 209 | Note: Starting with LuaSocket 2.1, the host name resolution | ||
| 210 | depends on whether the socket was created by <a | ||
| 211 | href=#socket.tcp><tt>socket.tcp</tt></a> or <a | ||
| 212 | href=#socket.tcp6><tt>socket.tcp6</tt></a>. Addresses from | ||
| 213 | the appropriate family are tried in succession until the | ||
| 214 | first success or until the last failure. | ||
| 215 | </p> | ||
| 216 | |||
| 183 | <!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 217 | <!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 184 | 218 | ||
| 185 | <p class=name id=getpeername> | 219 | <p class=name id="getpeername"> |
| 186 | client:<b>getpeername()</b> | 220 | client:<b>getpeername()</b> |
| 187 | </p> | 221 | </p> |
| 188 | 222 | ||
| @@ -202,7 +236,7 @@ Note: It makes no sense to call this method on server objects. | |||
| 202 | 236 | ||
| 203 | <!-- getsockname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 237 | <!-- getsockname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 204 | 238 | ||
| 205 | <p class=name id=getsockname> | 239 | <p class=name id="getsockname"> |
| 206 | master:<b>getsockname()</b><br> | 240 | master:<b>getsockname()</b><br> |
| 207 | client:<b>getsockname()</b><br> | 241 | client:<b>getsockname()</b><br> |
| 208 | server:<b>getsockname()</b> | 242 | server:<b>getsockname()</b> |
| @@ -219,7 +253,7 @@ the port. In case of error, the method returns <b><tt>nil</tt></b>. | |||
| 219 | 253 | ||
| 220 | <!-- getstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 254 | <!-- getstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 221 | 255 | ||
| 222 | <p class=name id=getstats> | 256 | <p class=name id="getstats"> |
| 223 | master:<b>getstats()</b><br> | 257 | master:<b>getstats()</b><br> |
| 224 | client:<b>getstats()</b><br> | 258 | client:<b>getstats()</b><br> |
| 225 | server:<b>getstats()</b><br> | 259 | server:<b>getstats()</b><br> |
| @@ -237,7 +271,7 @@ and the age of the socket object in seconds. | |||
| 237 | 271 | ||
| 238 | <!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 272 | <!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 239 | 273 | ||
| 240 | <p class=name id=listen> | 274 | <p class=name id="listen"> |
| 241 | master:<b>listen(</b>backlog<b>)</b> | 275 | master:<b>listen(</b>backlog<b>)</b> |
| 242 | </p> | 276 | </p> |
| 243 | 277 | ||
| @@ -265,7 +299,7 @@ method returns <b><tt>nil</tt></b> followed by an error message. | |||
| 265 | 299 | ||
| 266 | <!-- receive ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 300 | <!-- receive ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 267 | 301 | ||
| 268 | <p class=name id=receive> | 302 | <p class=name id="receive"> |
| 269 | client:<b>receive(</b>[pattern [, prefix]]<b>)</b> | 303 | client:<b>receive(</b>[pattern [, prefix]]<b>)</b> |
| 270 | </p> | 304 | </p> |
| 271 | 305 | ||
| @@ -316,7 +350,7 @@ too. | |||
| 316 | 350 | ||
| 317 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 351 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 318 | 352 | ||
| 319 | <p class=name id=send> | 353 | <p class=name id="send"> |
| 320 | client:<b>send(</b>data [, i [, j]]<b>)</b> | 354 | client:<b>send(</b>data [, i [, j]]<b>)</b> |
| 321 | </p> | 355 | </p> |
| 322 | 356 | ||
| @@ -354,7 +388,7 @@ instead of calling the method several times. | |||
| 354 | 388 | ||
| 355 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 389 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 356 | 390 | ||
| 357 | <p class=name id=setoption> | 391 | <p class=name id="setoption"> |
| 358 | client:<b>setoption(</b>option [, value]<b>)</b><br> | 392 | client:<b>setoption(</b>option [, value]<b>)</b><br> |
| 359 | server:<b>setoption(</b>option [, value]<b>)</b> | 393 | server:<b>setoption(</b>option [, value]<b>)</b> |
| 360 | </p> | 394 | </p> |
| @@ -392,8 +426,11 @@ used in validating addresses supplied in a call to | |||
| 392 | <a href=#bind><tt>bind</tt></a> should allow reuse of local addresses; | 426 | <a href=#bind><tt>bind</tt></a> should allow reuse of local addresses; |
| 393 | 427 | ||
| 394 | <li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt> | 428 | <li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt> |
| 395 | disables the Nagle's algorithm for the connection. | 429 | disables the Nagle's algorithm for the connection; |
| 396 | 430 | ||
| 431 | <li> '<tt>ipv6-v6only</tt>': | ||
| 432 | Setting this option to <tt>true</tt> restricts an <tt>inet6</tt> socket to | ||
| 433 | sending and receiving only IPv6 packets. | ||
| 397 | </ul> | 434 | </ul> |
| 398 | 435 | ||
| 399 | <p class=return> | 436 | <p class=return> |
| @@ -407,7 +444,7 @@ Note: The descriptions above come from the man pages. | |||
| 407 | 444 | ||
| 408 | <!-- getoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 445 | <!-- getoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 409 | 446 | ||
| 410 | <p class=name id=getoption> | 447 | <p class=name id="getoption"> |
| 411 | client:<b>getoption(</b>option)</b><br> | 448 | client:<b>getoption(</b>option)</b><br> |
| 412 | server:<b>getoption(</b>option)</b> | 449 | server:<b>getoption(</b>option)</b> |
| 413 | </p> | 450 | </p> |
| @@ -433,13 +470,9 @@ The method returns the option <tt>value</tt> in case of success, or | |||
| 433 | <b><tt>nil</tt></b> followed by an error message otherwise. | 470 | <b><tt>nil</tt></b> followed by an error message otherwise. |
| 434 | </p> | 471 | </p> |
| 435 | 472 | ||
| 436 | <p class=note> | ||
| 437 | Note: The descriptions above come from the man pages. | ||
| 438 | </p> | ||
| 439 | |||
| 440 | <!-- setstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 473 | <!-- setstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 441 | 474 | ||
| 442 | <p class=name id=setstats> | 475 | <p class=name id="setstats"> |
| 443 | master:<b>setstats(</b>received, sent, age<b>)</b><br> | 476 | master:<b>setstats(</b>received, sent, age<b>)</b><br> |
| 444 | client:<b>setstats(</b>received, sent, age<b>)</b><br> | 477 | client:<b>setstats(</b>received, sent, age<b>)</b><br> |
| 445 | server:<b>setstats(</b>received, sent, age<b>)</b><br> | 478 | 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. | |||
| 462 | 495 | ||
| 463 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 496 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 464 | 497 | ||
| 465 | <p class=name id=settimeout> | 498 | <p class=name id="settimeout"> |
| 466 | master:<b>settimeout(</b>value [, mode]<b>)</b><br> | 499 | master:<b>settimeout(</b>value [, mode]<b>)</b><br> |
| 467 | client:<b>settimeout(</b>value [, mode]<b>)</b><br> | 500 | client:<b>settimeout(</b>value [, mode]<b>)</b><br> |
| 468 | server:<b>settimeout(</b>value [, mode]<b>)</b> | 501 | server:<b>settimeout(</b>value [, mode]<b>)</b> |
| @@ -519,7 +552,7 @@ contained verbs making their imperative nature obvious. | |||
| 519 | 552 | ||
| 520 | <!-- shutdown +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 553 | <!-- shutdown +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 521 | 554 | ||
| 522 | <p class=name id=shutdown> | 555 | <p class=name id="shutdown"> |
| 523 | client:<b>shutdown(</b>mode<b>)</b><br> | 556 | client:<b>shutdown(</b>mode<b>)</b><br> |
| 524 | </p> | 557 | </p> |
| 525 | 558 | ||
| @@ -543,7 +576,7 @@ This function returns 1. | |||
| 543 | 576 | ||
| 544 | <!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 577 | <!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 545 | 578 | ||
| 546 | <p class=name id=dirty> | 579 | <p class=name id="dirty"> |
| 547 | master:<b>dirty()</b><br> | 580 | master:<b>dirty()</b><br> |
| 548 | client:<b>dirty()</b><br> | 581 | client:<b>dirty()</b><br> |
| 549 | server:<b>dirty()</b> | 582 | server:<b>dirty()</b> |
| @@ -563,7 +596,7 @@ Note: <b>This is an internal method, any use is unlikely to be portable.</b> | |||
| 563 | 596 | ||
| 564 | <!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 597 | <!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 565 | 598 | ||
| 566 | <p class=name id=getfd> | 599 | <p class=name id="getfd"> |
| 567 | master:<b>getfd()</b><br> | 600 | master:<b>getfd()</b><br> |
| 568 | client:<b>getfd()</b><br> | 601 | client:<b>getfd()</b><br> |
| 569 | server:<b>getfd()</b> | 602 | server:<b>getfd()</b> |
| @@ -583,7 +616,7 @@ Note: <b>This is an internal method, any use is unlikely to be portable.</b> | |||
| 583 | 616 | ||
| 584 | <!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 617 | <!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 585 | 618 | ||
| 586 | <p class=name id=setfd> | 619 | <p class=name id="setfd"> |
| 587 | master:<b>setfd(</b>fd<b>)</b><br> | 620 | master:<b>setfd(</b>fd<b>)</b><br> |
| 588 | client:<b>setfd(</b>fd<b>)</b><br> | 621 | client:<b>setfd(</b>fd<b>)</b><br> |
| 589 | server:<b>setfd(</b>fd<b>)</b> | 622 | server:<b>setfd(</b>fd<b>)</b> |
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 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
diff --git a/doc/url.html b/doc/url.html index 9f234d9..6ff673d 100644 --- a/doc/url.html +++ b/doc/url.html | |||
| @@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | <!-- url ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 37 | <!-- url ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 38 | 38 | ||
| 39 | <h2 id=url>URL</h2> | 39 | <h2 id="url">URL</h2> |
| 40 | 40 | ||
| 41 | <p> | 41 | <p> |
| 42 | The <tt>url</tt> namespace provides functions to parse, protect, | 42 | The <tt>url</tt> namespace provides functions to parse, protect, |
| @@ -69,7 +69,7 @@ An URL is defined by the following grammar: | |||
| 69 | 69 | ||
| 70 | <!-- absolute +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 70 | <!-- absolute +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 71 | 71 | ||
| 72 | <p class=name id=absolute> | 72 | <p class=name id="absolute"> |
| 73 | url.<b>absolute(</b>base, relative<b>)</b> | 73 | url.<b>absolute(</b>base, relative<b>)</b> |
| 74 | </p> | 74 | </p> |
| 75 | 75 | ||
| @@ -125,7 +125,7 @@ g;x?y#s = http://a/b/c/g;x?y#s | |||
| 125 | 125 | ||
| 126 | <!-- build ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 126 | <!-- build ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 127 | 127 | ||
| 128 | <p class=name id=build> | 128 | <p class=name id="build"> |
| 129 | url.<b>build(</b>parsed_url<b>)</b> | 129 | url.<b>build(</b>parsed_url<b>)</b> |
| 130 | </p> | 130 | </p> |
| 131 | 131 | ||
| @@ -146,7 +146,7 @@ The function returns a string with the built URL. | |||
| 146 | 146 | ||
| 147 | <!-- build_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 147 | <!-- build_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 148 | 148 | ||
| 149 | <p class=name id=build_path> | 149 | <p class=name id="build_path"> |
| 150 | url.<b>build_path(</b>segments, unsafe<b>)</b> | 150 | url.<b>build_path(</b>segments, unsafe<b>)</b> |
| 151 | </p> | 151 | </p> |
| 152 | 152 | ||
| @@ -200,7 +200,7 @@ code = url.escape("/#?;") | |||
| 200 | 200 | ||
| 201 | <!-- parse ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 201 | <!-- parse ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 202 | 202 | ||
| 203 | <p class=name id=parse> | 203 | <p class=name id="parse"> |
| 204 | url.<b>parse(</b>url, default<b>)</b> | 204 | url.<b>parse(</b>url, default<b>)</b> |
| 205 | </p> | 205 | </p> |
| 206 | 206 | ||
| @@ -265,7 +265,7 @@ parsed_url = url.parse("ftp://root:passwd@unsafe.org/pub/virus.exe;type=i") | |||
| 265 | 265 | ||
| 266 | <!-- parse_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 266 | <!-- parse_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 267 | 267 | ||
| 268 | <p class=name id=parse_path> | 268 | <p class=name id="parse_path"> |
| 269 | url.<b>parse_path(</b>path<b>)</b> | 269 | url.<b>parse_path(</b>path<b>)</b> |
| 270 | </p> | 270 | </p> |
| 271 | 271 | ||
diff --git a/makefile.dist b/makefile.dist index e4f8da8..fbd6681 100644 --- a/makefile.dist +++ b/makefile.dist | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #-------------------------------------------------------------------------- | 1 | #-------------------------------------------------------------------------- |
| 2 | # Distribution makefile | 2 | # Distribution makefile |
| 3 | #-------------------------------------------------------------------------- | 3 | #-------------------------------------------------------------------------- |
| 4 | DIST = luasocket-2.0.3 | 4 | DIST = luasocket-2.1.1-rc1 |
| 5 | 5 | ||
| 6 | TEST = \ | 6 | TEST = \ |
| 7 | test/README \ | 7 | test/README \ |
diff --git a/src/luasocket.h b/src/luasocket.h index 608ff7b..09e758d 100644 --- a/src/luasocket.h +++ b/src/luasocket.h | |||
| @@ -11,8 +11,8 @@ | |||
| 11 | /*-------------------------------------------------------------------------*\ | 11 | /*-------------------------------------------------------------------------*\ |
| 12 | * Current socket library version | 12 | * Current socket library version |
| 13 | \*-------------------------------------------------------------------------*/ | 13 | \*-------------------------------------------------------------------------*/ |
| 14 | #define LUASOCKET_VERSION "LuaSocket 2.1.1" | 14 | #define LUASOCKET_VERSION "LuaSocket 2.1.1-rc1" |
| 15 | #define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2011 Diego Nehab" | 15 | #define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2012 Diego Nehab" |
| 16 | #define LUASOCKET_AUTHORS "Diego Nehab" | 16 | #define LUASOCKET_AUTHORS "Diego Nehab" |
| 17 | 17 | ||
| 18 | /*-------------------------------------------------------------------------*\ | 18 | /*-------------------------------------------------------------------------*\ |
| @@ -13,8 +13,8 @@ | |||
| 13 | /*-------------------------------------------------------------------------*\ | 13 | /*-------------------------------------------------------------------------*\ |
| 14 | * Current MIME library version | 14 | * Current MIME library version |
| 15 | \*-------------------------------------------------------------------------*/ | 15 | \*-------------------------------------------------------------------------*/ |
| 16 | #define MIME_VERSION "MIME 1.0.3" | 16 | #define MIME_VERSION "MIME 1.0.3-rc1" |
| 17 | #define MIME_COPYRIGHT "Copyright (C) 2004-2009 Diego Nehab" | 17 | #define MIME_COPYRIGHT "Copyright (C) 2004-2012 Diego Nehab" |
| 18 | #define MIME_AUTHORS "Diego Nehab" | 18 | #define MIME_AUTHORS "Diego Nehab" |
| 19 | 19 | ||
| 20 | /*-------------------------------------------------------------------------*\ | 20 | /*-------------------------------------------------------------------------*\ |
