Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge from unstable

  • Loading branch information...
commit a8f9003febd5df1b8cfe7cd0823de3f3e410ffc7 2 parents 9a1ae29 + 8692d0a
@drahosp drahosp authored
Showing with 3,721 additions and 1,784 deletions.
  1. +3 −0  .gitignore
  2. +27 −5 CMakeLists.txt
  3. +5 −6 FIX
  4. +2 −2 LICENSE
  5. +34 −10 NEW
  6. +2 −2 README
  7. +53 −0 TODO
  8. +0 −60 config
  9. +60 −9 doc/dns.html
  10. +7 −7 doc/ftp.html
  11. +17 −18 doc/http.html
  12. +37 −62 doc/index.html
  13. +28 −58 doc/installation.html
  14. +4 −4 doc/introduction.html
  15. +4 −4 doc/ltn12.html
  16. +9 −9 doc/mime.html
  17. +24 −11 doc/reference.html
  18. +13 −13 doc/smtp.html
  19. +65 −18 doc/socket.html
  20. +160 −31 doc/tcp.html
  21. +146 −23 doc/udp.html
  22. +12 −13 doc/url.html
  23. +0 −1  etc/b64.lua
  24. +0 −1  etc/check-links.lua
  25. +22 −23 etc/dict.lua
  26. +1 −2  etc/dispatch.lua
  27. +0 −1  etc/eol.lua
  28. +53 −54 etc/get.lua
  29. +4 −5 etc/lp.lua
  30. +0 −1  etc/qp.lua
  31. +34 −35 etc/tftp.lua
  32. +0 −9 gem/makefile
  33. +16 −28 luasocket.sln
  34. +15 −42 makefile
  35. +5 −2 makefile.dist
  36. +121 −55 mime.vcproj
  37. +1 −1  samples/cddb.lua
  38. +0 −1  samples/daytimeclnt.lua
  39. +0 −1  samples/echoclnt.lua
  40. +0 −1  samples/echosrvr.lua
  41. +0 −1  samples/listener.lua
  42. +18 −0 samples/mclisten.lua
  43. +20 −0 samples/mcsend.lua
  44. +0 −1  samples/talker.lua
  45. +0 −1  samples/tinyirc.lua
  46. +147 −70 socket.vcproj
  47. +13 −4 src/auxiliar.c
  48. +2 −3 src/auxiliar.h
  49. +16 −8 src/buffer.c
  50. +2 −4 src/buffer.h
  51. +1 −3 src/except.c
  52. +0 −2  src/except.h
  53. +2 −3 src/ftp.lua
  54. +99 −0 src/headers.lua
  55. +6 −5 src/http.lua
  56. +183 −67 src/inet.c
  57. +7 −9 src/inet.h
  58. +0 −2  src/io.c
  59. +0 −2  src/io.h
  60. +0 −1  src/ltn12.lua
  61. +2 −4 src/luasocket.c
  62. +6 −4 src/luasocket.h
  63. +237 −60 src/makefile
  64. +20 −20 src/mbox.lua
  65. +45 −41 src/mime.c
  66. +2 −4 src/mime.h
  67. +0 −2  src/mime.lua
  68. +129 −16 src/options.c
  69. +25 −14 src/options.h
  70. +35 −19 src/select.c
  71. +0 −2  src/select.h
  72. +183 −0 src/serial.c
  73. +5 −4 src/smtp.lua
  74. +4 −2 src/socket.h
  75. +52 −17 src/socket.lua
  76. +184 −55 src/tcp.c
  77. +1 −2  src/tcp.h
  78. +16 −6 src/timeout.c
  79. +0 −2  src/timeout.h
  80. +2 −2 src/tp.lua
  81. +109 −39 src/udp.c
  82. +1 −2  src/udp.h
  83. +15 −31 src/unix.c
  84. +1 −3 src/unix.h
  85. +70 −65 src/url.lua
  86. +96 −13 src/usocket.c
  87. +4 −2 src/usocket.h
  88. +4 −6 src/wsocket.c
  89. +6 −3 src/wsocket.h
  90. +2 −0  test/README
  91. +32 −0 test/find-connect-limit
  92. +4 −4 test/ftptest.lua
  93. +3 −0  test/hello.lua
  94. +99 −99 test/httptest.lua
  95. +24 −0 test/mimetest.lua
  96. +52 −52 test/smtptest.lua
  97. +41 −0 test/tcp-getoptions
  98. +136 −54 test/testclnt.lua
  99. +73 −0 test/testing_thread.c
  100. +2 −0  test/testmesg.lua
  101. +7 −2 test/testsrvr.lua
  102. +7 −7 test/testsupport.lua
  103. +25 −0 test/udp-zero-length-send
  104. +37 −0 test/udp-zero-length-send-recv
  105. +422 −311 test/urltest.lua
  106. +1 −1  test/utestclnt.lua
View
3  .gitignore
@@ -0,0 +1,3 @@
+*.o
+*.so
+*.so.*
View
32 CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (C) 2007-2012 LuaDist.
-# Created by Peter Drahoš
+# Created by Peter Drahoš, David Manura
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the COPYRIGHT file distributed with LuaDist.
# Please note that the package source code is licensed under its own license.
@@ -39,6 +39,7 @@ install_lua_module ( ltn12 src/ltn12.lua )
install_lua_module ( mime src/mime.lua )
install_lua_module ( socket src/socket.lua )
install_lua_module ( socket.ftp src/ftp.lua )
+install_lua_module ( socket.headers src/headers.lua )
install_lua_module ( socket.http src/http.lua )
install_lua_module ( socket.smtp src/smtp.lua )
install_lua_module ( socket.tp src/tp.lua )
@@ -50,8 +51,29 @@ install_example ( samples/ )
install_doc ( doc/ )
install_data ( README NEW LICENSE )
-#2DO: how to spawn testsvr.lua to run in parallel with testclnt.lua?
-#~ add_lua_test ( test/testclnt.lua )
-file ( WRITE t/t.lua " require 'socket' " )
# very basic test
-add_lua_test ( t/t.lua )
+file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/t/t.lua " require 'socket' " )
+add_lua_test ( ${CMAKE_CURRENT_BINARY_DIR}/t/t.lua )
+
+# test with client-server.
+# This is more complicated because the test suite client and server must be
+# run in different threads (or different processes).
+find_package ( Threads )
+if ( Threads_FOUND )
+ add_lua_module ( testing_thread test/testing_thread.c LINK ${CMAKE_THREAD_LIBS_INIT} )
+ file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/t/clientserver.lua "
+ local socket = require 'socket'
+ function sleep(sec) socket.select(nil, nil, sec) end
+ print('RUN_THREAD=', RUN_THREAD)
+ if RUN_THREAD then
+ dofile '${CMAKE_CURRENT_SOURCE_DIR}/test/testsrvr.lua'
+ else
+ require 'testing_thread' '${CMAKE_CURRENT_BINARY_DIR}/clientserver.lua'
+ sleep(2) -- allow some time for server to start
+ dofile '${CMAKE_CURRENT_SOURCE_DIR}/test/testclnt.lua'
+ end
+ " )
+ add_lua_test ( ${CMAKE_CURRENT_BINARY_DIR}/t/clientserver.lua )
+else ()
+ message ( WARNING "skipping tests (no threading)" )
+endif ()
View
11 FIX
@@ -1,15 +1,14 @@
-http was preserving old host header during redirects
-fix smtp.send hang on source error
-add create field to FTP and SMTP and fix HTTP ugliness
-clean timeout argument to open functions in SMTP, HTTP and FTP
-eliminate globals from namespaces created by module().
-
+http was preserving old host header during redirects
+fix smtp.send hang on source error
+add create field to FTP and SMTP and fix HTTP ugliness
+clean timeout argument to open functions in SMTP, HTTP and FTP
+eliminate globals from namespaces created by module().
url.absolute was not working when base_url was already parsed
http.request was redirecting even when the location header was empty
tcp{client}:shutdown() was checking for group instead of class.
View
4 LICENSE
@@ -1,5 +1,5 @@
-LuaSocket 2.0.2 license
-Copyright � 2004-2007 Diego Nehab
+LuaSocket 2.1 license
+Copyright � 2004-2012 Diego Nehab
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
View
44 NEW
@@ -2,13 +2,37 @@ What's New
This is just a bug-fix/update release.
- * Improved: http.request() now supports deprecated HTTP/0.9
- servers (Florian Berger)
- * Fixed: could return "timedout" instead of "timeout" (Leo Leo)
- * Fixed: crash when reading '*a' on closed socket (Paul Ducklin);
- * Fixed: return values are consistent when reading from closed sockets;
- * Fixed: case sensitivity in headers of multipart messages in
- smtp.message() (Graham Henstridge);
- * Fixed a couple instances of error() being called instead of base.error(). These would cause an error when an error was reported. :) (Ketmar Dark);
- * Fixed: test script now uses pairs() iterator instead of the old
- Lua syntax (Robert Dodier).
+ * Fixed: manual sample of HTTP authentication now uses correct
+ "authorization" header (Alexandre Ittner);
+ * Fixed: failure on bind() was destroying the socket (Sam Roberts);
+ * Fixed: receive() returns immediatelly if prefix can satisfy
+ bytes requested (M Joonas Pihlaja);
+ * Fixed: multicast didn't work on Windows, or anywhere
+ else for that matter (Herbert Leuwer, Adrian Sietsma);
+ * Fixed: select() now reports an error when called with more
+ sockets than FD_SETSIZE (Lorenzo Leonini);
+ * Fixed: manual links to home.html changed to index.html (Robert Hahn);
+ * Fixed: mime.unb64() would return an empty string on results that started
+ with a null character (Robert Raschke);
+ * Fixed: HTTP now automatically redirects on 303 and 307 (Jonathan Gray);
+ * Fixed: calling sleep() with negative numbers could
+ block forever, wasting CPU. Now it returns immediately (MPB);
+ * Improved: FTP commands are now sent in upper case to
+ help buggy servers (Anders Eurenius);
+ * Improved: known headers now sent in canonic
+ capitalization to help buggy servers (Joseph Stewart);
+ * Improved: Clarified tcp:receive() in the manual (MPB);
+ * Improved: Decent makefiles (LHF).
+ * Fixed: RFC links in documentation now point to IETF (Cosmin Apreutesei).
+
+
+ Yuri's bug?
+ Dahlberg
+ Sam Roberts
+ Thomas Harning Jr.
+ Sebastien Perin
+ remove getn in all files
+ ltn12.pump.all(
+ ltn12.source.file(io.open("original.png")),
+ ltn12.sink.file(io.open("copy.png", "wb"))
+ )
View
4 README
@@ -1,5 +1,5 @@
-This is the LuaSocket 2.0.1. It has been tested on WinXP, Mac OS X,
-and Linux. Please use the Lua mailing list to report any bugs
+This is the LuaSocket 2.1. It has been tested on --[[WinXP--]], Mac OS X,
+and --[[Linux--]]. Please use the Lua mailing list to report any bugs
(or "features") you encounter.
Have fun,
View
53 TODO
@@ -1,3 +1,56 @@
+- document the new bind and connect behavior.
+- shouldn't we instead make the code compatible to Lua 5.2
+ without any compat stuff, and use a compatibility layer to
+ make it work on 5.1?
+- add what's new to manual
+- should there be an equivalent to tohostname for IPv6?
+- should we add service name resolution as well to getaddrinfo?
+- Maybe the sockaddr to presentation conversion should be done with getnameinfo()?
+
+- add http POST sample to manual
+ people keep asking stupid questions
+- documentation of dirty/getfd/setfd is problematic because of portability
+ same for unix and serial.
+ what to do about this? add a stronger disclaimer?
+- fix makefile with decent defaults?
+
+Done:
+
+- added IPv6 support to getsockname
+- simplified getpeername implementation
+- added family to return of getsockname and getpeername
+ and added modification to the manual to describe
+
+- connect and bind try all adresses returned by getaddrinfo
+- document headers.lua?
+- update copyright date everywhere?
+- remove RCSID from files?
+- move version to 2.1 rather than 2.1.1?
+- fixed url package to support ipv6 hosts
+- changed domain to family
+- implement getfamily methods.
+
+- remove references to Lua 5.0 from documentation, add 5.2?
+- update lua and luasocket version in samples in documentation
+- document ipv5_v6only default option being set?
+- document tcp6 and udp6
+- document dns.getaddrinfo
+- documented zero-sized datagram change?
+ no.
+- document unix socket and serial socket? add raw support?
+ no.
+- document getoption
+- merge luaL_typeerror into auxiliar to avoid using luaL prefix?
+
+
+
+
+
+
+
+
+
+
replace \r\n with \0xD\0xA in everything
New mime support
View
60 config
@@ -1,60 +0,0 @@
-#------
-# LuaSocket makefile configuration
-#
-
-#------
-# Output file names
-#
-EXT=so
-SOCKET_V=2.0.2
-MIME_V=1.0.2
-SOCKET_SO=socket.$(EXT).$(SOCKET_V)
-MIME_SO=mime.$(EXT).$(MIME_V)
-UNIX_SO=unix.$(EXT)
-
-#------
-# Lua includes and libraries
-#
-#LUAINC=-I/usr/local/include/lua50
-#LUAINC=-I/usr/local/include/lua5.1
-#LUAINC=-Ilua-5.1.1/src
-
-#------
-# Compat-5.1 directory
-#
-#COMPAT=compat-5.1r5
-
-#------
-# Top of your Lua installation
-# Relative paths will be inside the src tree
-#
-#INSTALL_TOP_SHARE=/usr/local/share/lua/5.0
-#INSTALL_TOP_LIB=/usr/local/lib/lua/5.0
-INSTALL_TOP_SHARE=/usr/local/share/lua/5.1
-INSTALL_TOP_LIB=/usr/local/lib/lua/5.1
-
-INSTALL_DATA=cp
-INSTALL_EXEC=cp
-
-#------
-# Compiler and linker settings
-# for Mac OS X
-#
-#CC=gcc
-#DEF= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN
-#CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common
-#LDFLAGS=-bundle -undefined dynamic_lookup
-#LD=export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
-
-#------
-# Compiler and linker settings
-# for Linux
-CC=gcc
-DEF=-DLUASOCKET_DEBUG
-CFLAGS= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic
-LDFLAGS=-O -shared -fpic
-LD=gcc
-
-#------
-# End of makefile configuration
-#
View
69 doc/dns.html
@@ -24,8 +24,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -39,12 +39,16 @@
<h2 id=dns>DNS</h2>
<p>
-Name resolution functions return <em>all</em> information obtained from the
-resolver in a table of the form:
+IPv4 name resolution functions
+<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>
<blockquote><tt>
-resolved = {<br>
+resolved4 = {<br>
&nbsp;&nbsp;name = <i>canonic-name</i>,<br>
&nbsp;&nbsp;alias = <i>alias-list</i>,<br>
&nbsp;&nbsp;ip = <i>ip-address-list</i><br>
@@ -55,6 +59,53 @@ <h2 id=dns>DNS</h2>
Note that the <tt>alias</tt> list can be empty.
</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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=gethostname>
@@ -72,7 +123,7 @@ <h2 id=dns>DNS</h2>
</p>
<p class=description>
-Converts from IP address to host name.
+Converts from IPv4 address to host name.
</p>
<p class=parameters>
@@ -93,7 +144,7 @@ <h2 id=dns>DNS</h2>
</p>
<p class=description>
-Converts from host name to IP address.
+Converts from host name to IPv4 address.
</p>
<p class=parameters>
@@ -113,8 +164,8 @@ <h2 id=dns>DNS</h2>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
14 doc/ftp.html
@@ -24,8 +24,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -42,7 +42,7 @@ <h2 id=ftp>FTP</h2>
FTP (File Transfer Protocol) is a protocol used to transfer files
between hosts. The <tt>ftp</tt> namespace offers thorough support
to FTP, under a simple interface. The implementation conforms to
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc0959.txt">RFC 959</a>.
+<a href="http://www.ietf.org/rfc/rfc959.txt">RFC 959</a>.
</p>
<p>
@@ -70,8 +70,8 @@ <h2 id=ftp>FTP</h2>
<p>
URLs MUST conform to
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc1738.txt">RFC
-1738</a>, that is, an URL is a string in the form:
+<a href="http://www.ietf.org/rfc/rfc1738.txt">RFC 1738</a>,
+that is, an URL is a string in the form:
</p>
<blockquote>
@@ -270,8 +270,8 @@ <h2 id=ftp>FTP</h2>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
35 doc/http.html
@@ -24,8 +24,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -36,7 +36,7 @@
<!-- http +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<h2 id=http>HTTP</h2>
+<h2 id="http">HTTP</h2>
<p>
HTTP (Hyper Text Transfer Protocol) is the protocol used to exchange
@@ -45,8 +45,7 @@ <h2 id=http>HTTP</h2>
protocol (i.e.,
the facilities that would be used by a web-browser implementation). The
implementation conforms to the HTTP/1.1 standard,
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2616.txt">RFC
-2616</a>.
+<a href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a>.
</p>
<p>
@@ -67,8 +66,7 @@ <h2 id=http>HTTP</h2>
<p>
URLs must conform to
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc1738.txt">RFC
-1738</a>,
+<a href="http://www.ietf.org/rfc/rfc1738.txt">RFC 1738</a>,
that is, an URL is a string in the form:
</p>
@@ -97,8 +95,9 @@ <h2 id=http>HTTP</h2>
</blockquote>
<p>
-Field names are case insensitive (as specified by the standard) and all
-functions work with lowercase field names.
+Field names are case insensitive (as specified by the standard) and all
+functions work with lowercase field names (but see
+<a href=socket.html#headers.canonic><tt>socket.headers.canonic</tt></a>).
Field values are left unmodified.
</p>
@@ -119,9 +118,10 @@ <h2 id=http>HTTP</h2>
<li> <tt>USERAGENT</tt>: default user agent reported to server.
</ul>
+
<!-- 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><br>
&nbsp;&nbsp;url = <i>string</i>,<br>
@@ -199,8 +199,7 @@ <h2 id=http>HTTP</h2>
URL was not found or some other useless page). To make sure the
operation was successful, check the returned status <tt>code</tt>. For
a list of the possible values and their meanings, refer to <a
-href="http://www.cs.princeton.edu/~diego/rfc/rfc2616.txt">RFC
-2616</a>.
+href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a>.
</p>
<p class=description>
@@ -259,7 +258,7 @@ <h2 id=http>HTTP</h2>
-- }
</pre>
-<p class=note id=post>
+<p class=note id="post">
Note: When sending a POST request, simple interface adds a
"<tt>Content-type: application/x-www-form-urlencoded</tt>"
header to the request. This is the type used by
@@ -267,7 +266,7 @@ <h2 id=http>HTTP</h2>
interface.
</p>
-<p class=note id=authentication>
+<p class=note id="authentication">
Note: Some URLs are protected by their
servers from anonymous download. For those URLs, the server must receive
some sort of authentication along with the request or it will deny
@@ -278,7 +277,7 @@ <h2 id=http>HTTP</h2>
The HTTP/1.1 standard defines two authentication methods: the Basic
Authentication Scheme and the Digest Authentication Scheme, both
explained in detail in
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2068.txt">RFC 2068</a>.
+<a href="http://www.ietf.org/rfc/rfc2068.txt">RFC 2068</a>.
</p>
<p class=note>The Basic Authentication Scheme sends
@@ -304,7 +303,7 @@ <h2 id=http>HTTP</h2>
-- the request directly.
r, c = http.request {
url = "http://www.example.com/private/index.html",
- headers = { authentication = "Basic " .. (mime.b64("fulano:silva")) }
+ headers = { authorization = "Basic " .. (mime.b64("fulano:silva")) }
}
</pre>
@@ -314,8 +313,8 @@ <h2 id=http>HTTP</h2>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
99 doc/index.html
@@ -24,8 +24,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -78,8 +78,8 @@ <h2 id=whatis>What is LuaSocket?</h2>
</p>
<p>
-Copyright &copy; 2004-2007 Diego Nehab. All rights reserved. <br>
-Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a>
+Copyright &copy; 1999-2012 Diego Nehab. All rights reserved. <br>
+Author: <A href="http://www.impa.br/~diego">Diego Nehab</a>
</p>
<!-- download +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -87,25 +87,18 @@ <h2 id=whatis>What is LuaSocket?</h2>
<h2 id=download>Download</h2>
<p>
-LuaSocket version 2.0.2 is now available for download! It is
-compatible with Lua&nbsp;5.1, and has
+LuaSocket version 2.1-rc1 is now available for download!
+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
are it works well on most UNIX distributions and Windows flavors.
</p>
<p>
The library can be downloaded in source code from the
-<a href=http://luaforge.net/projects/luasocket/>LuaSocket
-project page</a> at LuaForge.
-Besides the full C and Lua source code for the library, the distribution
-contains several examples, 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.
+<a href="https://github.com/diegonehab/luasocket/downloads">LuaSocket
+project page</a> at GitHub. Besides the full C and Lua source code
+for the library, the distribution contains several examples,
+this user's manual and basic test procedures.
</p>
<p> Take a look at the <a
@@ -118,14 +111,13 @@ <h2 id=download>Download</h2>
<h2 id=thanks>Special thanks</h2>
<p>
-Throughout LuaSocket's history, many people gave suggestions that helped
-improve it. For that, I thank the Lua community.
-Special thanks go to
-David Burgess, who has helped push the library to a new level of quality and
-from whom I have learned a lot of stuff that doesn't show up in RFCs.
-Special thanks also to Carlos Cassino, who played a big part in the
-extensible design seen in the C core of LuaSocket 2.0. Mike Pall
-has been helping a lot too! Thanks to you all!
+This marks the first release of LuaSocket that
+wholeheartedly embraces the open-source development
+philosophy. After a long hiatus, Matthew Wild finally
+convinced me it was time for a release including IPv6
+and Lua 5.2 support. Special thanks to Sam Roberts, Florian
+Zeitz, and Paul Aurich, Liam Devine, and everybody else that
+has helped bring this library back to life.
</p>
<!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -133,44 +125,27 @@ <h2 id=thanks>Special thanks</h2>
<h2 id=new>What's New</h2>
<p>
-2.0.2 is just a bug-fix/update release.
+Main changes for LuaSocket&nbsp;2.1-rc1 are IPv6 support
+and Lua&nbsp;5.2 compatibility.
</p>
<ul>
-<li> Improved: http.request() now supports deprecated
-HTTP/0.9 servers (Florian Berger);
-<li> Fixed: could return "timedout" instead of "timeout" (Leo Leo);
-<li> Fixed: crash when reading '*a' on closed socket (Paul Ducklin);
-<li> Fixed: return values are consistent when reading from closed sockets;
-<li> Fixed: case sensitivity in headers of multipart
-messages in smtp.message() (Graham Henstridge);
-<li> Fixed a couple instances of error() being called instead of
-base.error(). These would cause an error when an error was
-reported :) (Ketmar Dark);
-<li> Fixed: test script now uses pairs() iterator instead
-of the old Lua syntax (Robert Dodier).
-</ul>
-
-<p>
-2.0.1 is just a bug-fix/update release.
-</p>
-
+<li> Added: Compatible with Lua&nbsp;5.2 (using <tt>LUA_COMPAT_MODULE</tt>);
+<li> Added: IPv6 support;
<ul>
-<li> Updated: now using <tt>compat-5.1r5</tt>;
-<li> Improved: <tt>http.request</tt> is more robust to
-malformed URLs (Adrian Sietsma);
-<li> Improved: the simple <tt>http.request</tt> interface sends a
-"<tt>Content-type: application/x-www-form-urlencoded</tt>"
-header (William Trenker);
-<li> Improved: <tt>http.request</tt> is robust to evil
-servers that send inappropriate 100-continue messages
-(David Burgess);
-<li> Fixed: <tt>http.request</tt> was using the old host header during
-redirects (Florian Berger);
-<li> Fixed: sample <tt>unix.c</tt> had fallen through the
-cracks during development (Matthew Percival);
-<li> Fixed: error code was not being propagated correctly in
-ftp.lua (David Burgess).
+<li> <tt>Socket.connect</tt> and <tt>socket.bind</tt> support IPv6 addresses;
+<li> <tt>Getpeername</tt> and <tt>getsockname</tt> support
+IPv6 addresses, and return the socket family as a third value;
+<li> URL module updated to support IPv6 host names;
+<li> New <tt>socket.tcp6</tt> and <tt>socket.udp6</tt> functions;
+<li> New <tt>socket.dns.getaddrinfo</tt> function;
+</ul>
+<li> Added: <tt>getoption</tt> method;
+<li> Fixed: <tt>url.unescape</tt> was returning additional values;
+<li> Fixed: Receiving zero-length datagram is now possible;
+<li> Improved: Hidden all internal library symbols;
+<li> Improved: Better error messages;
+<li> Improved: Better documentation of socket options.
</ul>
<!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -179,7 +154,7 @@ <h2 id=old>Old Versions</h2>
<p>
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
still available for those that have compatibility issues.
</p>
@@ -190,7 +165,7 @@ <h2 id=old>Old Versions</h2>
<hr>
<center>
<p class=bar>
-<a href="home.html#download">download</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -198,7 +173,7 @@ <h2 id=old>Old Versions</h2>
<p>
<small>
Last modified by Diego Nehab on <br>
-Wed Oct 3 02:07:59 BRT 2007
+Mon Apr 16 21:58:56 HKT 2012
</small>
</p>
</center>
View
86 doc/installation.html
@@ -25,8 +25,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -39,24 +39,16 @@
<h2>Installation</h2>
-<p> LuaSocket 2.0.2 uses the new package system for Lua 5.1.
-All Lua library developers are encouraged to update their libraries so that
-all libraries can coexist peacefully and users can benefit from the
-standardization and flexibility of the standard.
-</p>
-
-<p>
-Those stuck with Lua 5.0 will need the
-<a href=http://www.keplerproject.org/compat/>compat-5.1</a>
-module. It is maintained by
-<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> LuaSocket 2.1-rc still uses Lua&nbsp;5.1's package
+system. Users that have already made the switch to
+Lua&nbsp;5.2 should leave the default
+<tt>LUA_COMPAT_MODULE</tt> defined when compiling their Lua
+distribution for compatibility with LuaSocket. </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>
+<p> Here we 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>
@@ -64,14 +56,19 @@
directories, one for system dependent files, and another for system
independent files. Let's call these directories <tt>&lt;CDIR&gt;</tt>
and <tt>&lt;LDIR&gt;</tt>, respectively.
-For instance, in my laptop, I use '<tt>/usr/local/lib/lua/5.0</tt>' for
-<tt>&lt;CDIR&gt;</tt> and '<tt>/usr/local/share/lua/5.0</tt>' for
-<tt>&lt;LDIR&gt;</tt>. On Windows, sometimes only one directory is used, say
-'<tt>c:\program files\lua\5.0</tt>'. Here is the standard LuaSocket
+For example, in my laptp, Lua&nbsp;5.1 is configured to
+use '<tt>/usr/local/lib/lua/5.1</tt>' for
+<tt>&lt;CDIR&gt;</tt> and '<tt>/usr/local/share/lua/5.1</tt>' for
+<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>
<pre class=example>
-&lt;LDIR&gt;/compat-5.1.lua
&lt;LDIR&gt;/ltn12.lua
&lt;LDIR&gt;/socket.lua
&lt;CDIR&gt;/socket/core.dll
@@ -88,33 +85,6 @@
would be replaced by <tt>core.so</tt>.
</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>
<p> With the above setup, and an interpreter with shared library support,
@@ -122,19 +92,19 @@
<tt>require</tt> function to gain access to whatever module you need:</p>
<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; print(socket._VERSION)
---&gt; LuaSocket 2.0.2
+--&gt; LuaSocket 2.1-rc1
</pre>
<p> Each module loads their dependencies automatically, so you only need to
load the modules you directly depend upon: </p>
<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; 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
</pre>
@@ -144,8 +114,8 @@
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -153,7 +123,7 @@
<p>
<small>
Last modified by Diego Nehab on <br>
-Thu Apr 20 00:25:30 EDT 2006
+Mon Apr 16 21:01:42 HKT 2012
</small>
</p>
</center>
View
8 doc/introduction.html
@@ -25,8 +25,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -314,8 +314,8 @@ <h3 id=more>Support modules</h3>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
8 doc/ltn12.html
@@ -25,8 +25,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -411,8 +411,8 @@ <h3 id="source">Sources</h3>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
18 doc/mime.html
@@ -24,8 +24,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -44,11 +44,11 @@ <h2 id=mime>MIME</h2>
It also provides functions to break text into lines and change
the end-of-line convention.
MIME is described mainly in
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2045.txt">RFC 2045</a>,
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2046.txt">2046</a>,
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2047.txt">2047</a>,
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2047.txt">2048</a>, and
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2048.txt">2049</a>.
+<a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>,
+<a href="http://www.ietf.org/rfc/rfc2046.txt">2046</a>,
+<a href="http://www.ietf.org/rfc/rfc2047.txt">2047</a>,
+<a href="http://www.ietf.org/rfc/rfc2047.txt">2048</a>, and
+<a href="http://www.ietf.org/rfc/rfc2048.txt">2049</a>.
</p>
<p>
@@ -457,8 +457,8 @@ <h3 id=low>Low-level filters</h3>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
35 doc/reference.html
@@ -25,8 +25,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -42,9 +42,10 @@
<blockquote>
<a href="dns.html">DNS (in socket)</a>
<blockquote>
-<a href="dns.html#toip">toip</a>,
+<a href="dns.html#getaddrinfo">getaddrinfo</a>,
+<a href="dns.html#gethostname">gethostname</a>,
<a href="dns.html#tohostname">tohostname</a>,
-<a href="dns.html#gethostname">gethostname</a>.
+<a href="dns.html#toip">toip</a>.
</blockquote>
</blockquote>
@@ -108,9 +109,9 @@
<a href="mime.html">MIME</a>
<blockquote>
<a href="mime.html#high">high-level</a>:
-<a href="mime.html#normalize">normalize</a>,
<a href="mime.html#decode">decode</a>,
<a href="mime.html#encode">encode</a>,
+<a href="mime.html#normalize">normalize</a>,
<a href="mime.html#stuff">stuff</a>,
<a href="mime.html#wrap">wrap</a>.
</blockquote>
@@ -120,10 +121,10 @@
<a href="mime.html#dot">dot</a>,
<a href="mime.html#eol">eol</a>,
<a href="mime.html#qp">qp</a>,
-<a href="mime.html#wrp">wrp</a>,
-<a href="mime.html#qpwrp">qpwrp</a>.
+<a href="mime.html#qpwrp">qpwrp</a>,
<a href="mime.html#unb64">unb64</a>,
<a href="mime.html#unqp">unqp</a>,
+<a href="mime.html#wrp">wrp</a>.
</blockquote>
</blockquote>
@@ -142,19 +143,25 @@
<blockquote>
<a href="socket.html">Socket</a>
<blockquote>
+<a href="socket.html#bind">bind</a>,
+<a href="socket.html#connect">connect</a>,
<a href="socket.html#debug">_DEBUG</a>,
<a href="dns.html#dns">dns</a>,
<a href="socket.html#gettime">gettime</a>,
+<a href="socket.html#headers.canonic">headers.canonic</a>,
<a href="socket.html#newtry">newtry</a>,
<a href="socket.html#protect">protect</a>,
<a href="socket.html#select">select</a>,
<a href="socket.html#sink">sink</a>,
<a href="socket.html#skip">skip</a>,
<a href="socket.html#sleep">sleep</a>,
+<a href="socket.html#setsize">_SETSIZE</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="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>.
</blockquote>
</blockquote>
@@ -168,11 +175,16 @@
<a href="tcp.html#bind">bind</a>,
<a href="tcp.html#close">close</a>,
<a href="tcp.html#connect">connect</a>,
+<a href="tcp.html#dirty">dirty</a>,
+<a href="tcp.html#getfd">getfd</a>,
+<a href="tcp.html#getoption">getoption</a>,
<a href="tcp.html#getpeername">getpeername</a>,
<a href="tcp.html#getsockname">getsockname</a>,
<a href="tcp.html#getstats">getstats</a>,
+<a href="tcp.html#listen">listen</a>,
<a href="tcp.html#receive">receive</a>,
<a href="tcp.html#send">send</a>,
+<a href="tcp.html#setfd">setfd</a>,
<a href="tcp.html#setoption">setoption</a>,
<a href="tcp.html#setstats">setstats</a>,
<a href="tcp.html#settimeout">settimeout</a>,
@@ -186,6 +198,7 @@
<a href="udp.html">UDP (in socket)</a>
<blockquote>
<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#getsockname">getsockname</a>,
<a href="udp.html#receive">receive</a>,
@@ -220,8 +233,8 @@
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
26 doc/smtp.html
@@ -25,8 +25,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -48,14 +48,13 @@ <h2 id=smtp>SMTP</h2>
</p>
<p>The implementation conforms to the Simple Mail Transfer Protocol,
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2821.txt">RFC 2821</a>.
+<a href="http://www.ietf.org/rfc/rfc2821.txt">RFC 2821</a>.
Another RFC of interest is <a
-href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>,
+href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>,
which governs the Internet Message Format.
Multipart messages (those that contain attachments) are part
of the MIME standard, but described mainly
-in <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2046.txt">RFC
-2046</a>
+in <a href="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</a>
<p> In the description below, good understanding of <a
href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> LTN012, Filters
@@ -91,8 +90,9 @@ <h2 id=smtp>SMTP</h2>
</blockquote>
<p>
-Field names are case insensitive (as specified by the standard) and all
-functions work with lowercase field names.
+Field names are case insensitive (as specified by the standard) and all
+functions work with lowercase field names (but see
+<a href=socket.html#headers.canonic><tt>socket.headers.canonic</tt></a>).
Field values are left unmodified.
</p>
@@ -196,7 +196,7 @@ <h2 id=smtp>SMTP</h2>
</p>
<p class=note>
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>
+<a href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>
has two <em>important and short</em> sections, "3.6.3. Destination address
fields" and "5. Security considerations", explaining the proper
use of these headers. Here is a summary of what it says:
@@ -236,9 +236,9 @@ <h2 id=smtp>SMTP</h2>
<p class=note>
I hope this clarifies the issue. Otherwise, please refer to
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2821.txt">RFC 2821</a>
+<a href="http://www.ietf.org/rfc/rfc2821.txt">RFC 2821</a>
and
-<a href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>.
+<a href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>.
</p>
<pre class=example>
@@ -398,8 +398,8 @@ <h2 id=smtp>SMTP</h2>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
83 doc/socket.html
@@ -24,8 +24,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -94,6 +94,47 @@ <h2 id=socket>The socket namespace</h2>
with debug support.
</p>
+<!-- get time +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+
+<p class=name id=gettime>
+socket.<b>gettime()</b>
+</p>
+
+<p class=description>
+Returns the time in seconds, relative to the origin of the
+universe. You should subtract the values returned by this function
+to get meaningful values.
+</p>
+
+<pre class=example>
+t = socket.gettime()
+-- do stuff
+print(socket.gettime() - t .. " seconds elapsed")
+</pre>
+
+<!-- socket.headers ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+
+<p class=name id="headers.canonic">
+socket.headers.<b>canonic</b></p>
+
+<p> The <tt>socket.headers.canonic</tt> table
+is used by the HTTP and SMTP modules to translate from
+lowercase field names back into their canonic
+capitalization. When a lowercase field name exists as a key
+in this table, the associated value is substituted in
+whenever the field name is sent out.
+</p>
+
+<p>
+You can obtain the <tt>headers</tt> namespace if case run-time
+modifications are required by running:
+</p>
+
+<pre class=example>
+-- loads the headers module
+local headers = require("headers")
+</pre>
+
<!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=newtry>
@@ -200,6 +241,15 @@ <h2 id=socket>The socket namespace</h2>
</p>
<p class=note>
+<b>Note: </b>: <tt>select</tt> can monitor a limited number
+of sockets, as defined by the constant <tt>socket._SETSIZE</tt>. This
+number may be as high as 1024 or as low as 64 by default,
+depending on the system. It is usually possible to change this
+at compile time. Invoking <tt>select</tt> with a larger
+number of sockets will raise an error.
+</p>
+
+<p class=note>
<b>Important note</b>: a known bug in WinSock causes <tt>select</tt> to fail
on non-blocking TCP sockets. The function may return a socket as
writable even though the socket is <em>not</em> ready for sending.
@@ -217,6 +267,10 @@ <h2 id=socket>The socket namespace</h2>
it to <tt>select</tt>, it will be ignored.
</p>
+<p class=note>
+<b>Using select with non-socket objects</b>: Any object that implements <tt>getfd</tt> and <tt>dirty</tt> can be used with <tt>select</tt>, allowing objects from other libraries to be used within a <tt>socket.select</tt> driven loop.
+</p>
+
<!-- sink ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=sink>
@@ -288,8 +342,8 @@ <h2 id=socket>The socket namespace</h2>
</p>
<p class=parameters>
-<tt>Time</tt> is the number of seconds to sleep for.
-The function truncates <tt>time</tt> down to the nearest integer.
+<tt>Time</tt> is the number of seconds to sleep for. If
+<tt>time</tt> is negative, the function returns immediately.
</p>
<!-- source +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -324,24 +378,17 @@ <h2 id=socket>The socket namespace</h2>
The function returns a source with the appropriate behavior.
</p>
-<!-- time ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+<!-- setsize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=gettime>
-socket.<b>gettime()</b>
+<p class=name id=setsize>
+socket.<b>_SETSIZE</b>
</p>
<p class=description>
-Returns the time in seconds, relative to the origin of the
-universe. You should subtract the values returned by this function
-to get meaningful values.
+The maximum number of sockets that the <a
+href=#select><tt>select</tt></a> function can handle.
</p>
-<pre class=example>
-t = socket.gettime()
--- do stuff
-print(socket.gettime() - t .. " seconds elapsed")
-</pre>
-
<!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=try>
@@ -386,8 +433,8 @@ <h2 id=socket>The socket namespace</h2>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
191 doc/tcp.html
@@ -24,8 +24,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -36,16 +36,16 @@
<!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<h2 id=tcp>TCP</h2>
+<h2 id="tcp">TCP</h2>
<!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=socket.tcp>
+<p class=name id="socket.tcp">
socket.<b>tcp()</b>
</p>
<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
<a href=#listen><tt>listen</tt></a> (after a call to <a
href=#bind><tt>bind</tt></a>) or into a client object with
@@ -58,9 +58,34 @@ <h2 id=tcp>TCP</h2>
<b><tt>nil</tt></b> is returned, followed by an error message.
</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 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=accept>
+<p class=name id="accept">
server:<b>accept()</b>
</p>
@@ -87,7 +112,7 @@ <h2 id=tcp>TCP</h2>
<!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=bind>
+<p class=name id="bind">
master:<b>bind(</b>address, port<b>)</b>
</p>
@@ -116,7 +141,7 @@ <h2 id=tcp>TCP</h2>
<!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=close>
+<p class=name id="close">
master:<b>close()</b><br>
client:<b>close()</b><br>
server:<b>close()</b>
@@ -139,7 +164,7 @@ <h2 id=tcp>TCP</h2>
<!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=connect>
+<p class=name id="connect">
master:<b>connect(</b>address, port<b>)</b>
</p>
@@ -180,9 +205,18 @@ <h2 id=tcp>TCP</h2>
established.
</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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=getpeername>
+<p class=name id="getpeername">
client:<b>getpeername()</b>
</p>
@@ -191,8 +225,9 @@ <h2 id=tcp>TCP</h2>
</p>
<p class=return>
-Returns a string with the IP address of the peer, followed by the
-port number that peer is using for the connection.
+Returns a string with the IP address of the peer, the
+port number that peer is using for the connection,
+and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
In case of error, the method returns <b><tt>nil</tt></b>.
</p>
@@ -202,7 +237,7 @@ <h2 id=tcp>TCP</h2>
<!-- getsockname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=getsockname>
+<p class=name id="getsockname">
master:<b>getsockname()</b><br>
client:<b>getsockname()</b><br>
server:<b>getsockname()</b>
@@ -213,13 +248,15 @@ <h2 id=tcp>TCP</h2>
</p>
<p class=return>
-The method returns a string with local IP address and a number with
-the port. In case of error, the method returns <b><tt>nil</tt></b>.
+The method returns a string with local IP address, a number with
+the local port,
+and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
+In case of error, the method returns <b><tt>nil</tt></b>.
</p>
<!-- getstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=getstats>
+<p class=name id="getstats">
master:<b>getstats()</b><br>
client:<b>getstats()</b><br>
server:<b>getstats()</b><br>
@@ -237,7 +274,7 @@ <h2 id=tcp>TCP</h2>
<!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=listen>
+<p class=name id="listen">
master:<b>listen(</b>backlog<b>)</b>
</p>
@@ -265,7 +302,7 @@ <h2 id=tcp>TCP</h2>
<!-- receive ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=receive>
+<p class=name id="receive">
client:<b>receive(</b>[pattern [, prefix]]<b>)</b>
</p>
@@ -297,12 +334,12 @@ <h2 id=tcp>TCP</h2>
<p class=return>
If successful, the method returns the received pattern. In case of error,
-the method returns <tt><b>nil</b></tt> followed by an error message which
-can be the string '<tt>closed</tt>' in case the connection was
+the method returns <tt><b>nil</b></tt> followed by an error
+message, followed by a (possibly empty) string containing
+the partial that was received. The error message can be
+the string '<tt>closed</tt>' in case the connection was
closed before the transmission was completed or the string
'<tt>timeout</tt>' in case there was a timeout during the operation.
-Also, after the error message, the function returns the partial result of
-the transmission.
</p>
<p class=note>
@@ -316,7 +353,7 @@ <h2 id=tcp>TCP</h2>
<!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=send>
+<p class=name id="send">
client:<b>send(</b>data [, i [, j]]<b>)</b>
</p>
@@ -354,7 +391,7 @@ <h2 id=tcp>TCP</h2>
<!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=setoption>
+<p class=name id="setoption">
client:<b>setoption(</b>option [, value]<b>)</b><br>
server:<b>setoption(</b>option [, value]<b>)</b>
</p>
@@ -392,21 +429,53 @@ <h2 id=tcp>TCP</h2>
<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>
-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>
<p class=return>
-The method returns 1 in case of success, or <b><tt>nil</tt></b> otherwise.
+The method returns 1 in case of success, or <b><tt>nil</tt></b>
+followed by an error message otherwise.
</p>
<p class=note>
Note: The descriptions above come from the man pages.
</p>
+<!-- getoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+
+<p class=name id="getoption">
+client:<b>getoption(</b>option)</b><br>
+server:<b>getoption(</b>option)</b>
+</p>
+
+<p class=description>
+Gets options for the TCP 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>keepalive</tt>'
+<li> '<tt>linger</tt>'
+<li> '<tt>reuseaddr</tt>'
+<li> '<tt>tcp-nodelay</tt>'
+</ul>
+
+<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>
+
<!-- setstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=setstats>
+<p class=name id="setstats">
master:<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>
@@ -429,7 +498,7 @@ <h2 id=tcp>TCP</h2>
<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=settimeout>
+<p class=name id="settimeout">
master:<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>
@@ -486,7 +555,7 @@ <h2 id=tcp>TCP</h2>
<!-- shutdown +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<p class=name id=shutdown>
+<p class=name id="shutdown">
client:<b>shutdown(</b>mode<b>)</b><br>
</p>
@@ -508,14 +577,74 @@ <h2 id=tcp>TCP</h2>
This function returns 1.
</p>
+<!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+
+<p class=name id="dirty">
+master:<b>dirty()</b><br>
+client:<b>dirty()</b><br>
+server:<b>dirty()</b>
+</p>
+
+<p class=description>
+Check the read buffer status.
+</p>
+
+<p class=return>
+Returns <tt>true</tt> if there is any data in the read buffer, <tt>false</tt> otherwise.
+</p>
+
+<p class=note>
+Note: <b>This is an internal method, any use is unlikely to be portable.</b>
+</p>
+
+<!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+
+<p class=name id="getfd">
+master:<b>getfd()</b><br>
+client:<b>getfd()</b><br>
+server:<b>getfd()</b>
+</p>
+
+<p class=description>
+Returns the underling socket descriptor or handle associated to the object.
+</p>
+
+<p class=return>
+The descriptor or handle. In case the object has been closed, the return will be -1.
+</p>
+
+<p class=note>
+Note: <b>This is an internal method, any use is unlikely to be portable.</b>
+</p>
+
+<!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+
+<p class=name id="setfd">
+master:<b>setfd(</b>fd<b>)</b><br>
+client:<b>setfd(</b>fd<b>)</b><br>
+server:<b>setfd(</b>fd<b>)</b>
+</p>
+
+<p class=description>
+Sets the underling socket descriptor or handle associated to the object. The current one is simply replaced, not closed, and no other change to the object state is made.
+</p>
+
+<p class=return>
+No return value.
+</p>
+
+<p class=note>
+Note: <b>This is an internal method, any use is unlikely to be portable.</b>
+</p>
+
<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<div class=footer>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
169 doc/udp.html
@@ -24,8 +24,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -37,7 +37,7 @@
<!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
-<h2 id=udp>UDP</h2>
+<h2 id="udp">UDP</h2>
<!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -46,10 +46,12 @@ <h2 id=udp>UDP</h2>
</p>
<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="#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>,
@@ -66,6 +68,44 @@ <h2 id=udp>UDP</h2>
an error message.
</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 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class="name" id="close">
@@ -100,8 +140,12 @@ <h2 id=udp>UDP</h2>
associated with a connected UDP object.
</p>
-<p class="return">
-Returns the IP address and port number of the peer.
+
+<p class=return>
+Returns a string with the IP address of the peer, the
+port number that peer is using for the connection,
+and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
+In case of error, the method returns <b><tt>nil</tt></b>.
</p>
<p class="note">
@@ -119,10 +163,12 @@ <h2 id=udp>UDP</h2>
Returns the local address information associated to the object.
</p>
-<p class="return">
-The method returns a string with local IP
-address and a number with the port. In case of error, the method
-returns <b><tt>nil</tt></b>.
+
+<p class=return>
+The method returns a string with local IP address, a number with
+the local port,
+and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>").
+In case of error, the method returns <b><tt>nil</tt></b>.
</p>
<p class="note">
@@ -177,6 +223,40 @@ <h2 id=udp>UDP</h2>
efficient).
</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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class="name" id="send">
@@ -284,6 +364,15 @@ <h2 id=udp>UDP</h2>
and can result in up to 30% performance gains.
</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 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class="name" id="setsockname">
@@ -332,23 +421,57 @@ <h2 id=udp>UDP</h2>
name, and <tt>value</tt> depends on the option being set:
</p>
-<ul>
-<li>'<tt>dontroute</tt>': Setting this option to <tt>true</tt>
-indicates that outgoing messages should bypass the standard routing
-facilities;</li>
-<li>'<tt>broadcast</tt>': Setting this option to <tt>true</tt>
-requests permission to send broadcast datagrams on the
-socket.</li>
-</ul>
+<ul>
+<li> '<tt>dontroute</tt>': Indicates that outgoing
+messages should bypass the standard routing facilities.
+Receives a boolean value;
+<li> '<tt>broadcast</tt>': Requests permission to send
+broadcast datagrams on the socket.
+Receives a boolean value;
+<li> '<tt>reuseaddr</tt>': Indicates that the rules used in
+validating addresses supplied in a <tt>bind()</tt> call
+should allow reuse of local addresses.
+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>
<p class="return">
The method returns 1 in case of success, or
<b><tt>nil</tt></b> followed by an error message otherwise.
</p>
-<p class="note">
-Note: The descriptions above come from the man
-pages.
+<p class=note>
+Note: The descriptions above come from the man pages.
</p>
<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -397,8 +520,8 @@ <h2 id=udp>UDP</h2>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
View
25 doc/url.html
@@ -24,8 +24,8 @@
</td></tr>