From f37e0260261f7691246429d227cf7124c291e8b1 Mon Sep 17 00:00:00 2001
From: Diego Nehab
-Name resolution functions return all information obtained from the
-resolver in a table of the form:
+IPv4 name resolution functions
+dns.toip
+and
+dns.tohostname
+return all information obtained from
+the resolver in a table of the form:
DNS
-resolved = {
+resolved4 = {
name = canonic-name,
alias = alias-list,
ip = ip-address-list
@@ -55,6 +59,53 @@ resolved = {
Note that the alias list can be empty.
+The more general name resolution function +dns.getaddrinfo, which +supports both IPv6 and IPv4, +returns all information obtained from +the resolver in a table of the form: +
+ ++resolved6 = {+ +
+ [1] = {
+ family = family-name-1,
+ addr = address-1
+ },
+ ...
+ [n] = {
+ family = family-name-n,
+ addr = address-n
+ }
+} +
+Here, family contains the string "inet" for IPv4 +addresses, and "inet6" for IPv6 addresses. +
+ + + ++socket.dns.getaddrinfo(address) +
+ ++Converts from host name to address. +
+ ++Address can be an IPv4 or IPv6 address or host name. +
+ ++The function returns a table with all information returned by +the resolver. In case of error, the function returns nil +followed by an error message. +
+@@ -72,7 +123,7 @@ socket.dns.tohostname(address)
-Converts from IP address to host name. +Converts from IPv4 address to host name.
@@ -93,7 +144,7 @@ socket.dns.toip(address)
-Converts from host name to IP address. +Converts from host name to IPv4 address.
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 @@ -
HTTP (Hyper Text Transfer Protocol) is the protocol used to exchange @@ -119,7 +119,7 @@ the HTTP module: -
+
http.request(url [, body])
http.request{
url = string,
@@ -256,7 +256,7 @@ r, c, h = http.request {
-- }
-
+
Note: When sending a POST request, simple interface adds a "Content-type: application/x-www-form-urlencoded" header to the request. This is the type used by @@ -264,7 +264,7 @@ HTML forms. If you need another type, use the generic interface.
-+
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 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.
-Copyright © 2004-2007 Diego Nehab. All rights reserved.
-Author: Diego Nehab
+Copyright © 1999-2012 Diego Nehab. All rights reserved.
+Author: Diego Nehab
-LuaSocket version 2.0.3 is now available for download! It is -compatible with Lua 5.1, and has +LuaSocket version 2.1.1-rc1 is now available for download! +It is compatible with Lua 5.1 and 5.2, and has been tested on Windows XP, Linux, and Mac OS X. Chances are it works well on most UNIX distributions and Windows flavors.
The library can be downloaded in source code from the -LuaSocket -project page 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. -
- --Danilo Tuler is maintaining Win32 binaries for LuaSocket, which are also -available from LuaForge. These are compatible with the -LuaBinaries, -also available from LuaForge. +LuaSocket +project page 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.
Take a look at the Special thanks
-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.
-2.0.3 is just a bug-fix/update release.
+Main changes for LuaSocket 2.1.1-rc1 are IPv6 support
+and Lua 5.2 compatibility.
All previous versions of the LuaSocket library can be downloaded
+href="http://www.impa.br/~diego/software/luasocket/old">
here. Although these versions are no longer supported, they are
still available for those that have compatibility issues.
Last modified by Diego Nehab on 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.
- LuaSocket 2.1.1-rc still uses Lua 5.1's package
+system. Users that have already made the switch to
+Lua 5.2 should leave the default
+LUA_COMPAT_MODULE defined when compiling their Lua
+distribution for compatibility with LuaSocket.
-Those stuck with Lua 5.0 will need the
-compat-5.1
-module. It is maintained by
-The Kepler
-Project's team, and implements the Lua 5.1 package proposal
-on top of Lua 5.0. 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. 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. What's New
-
@@ -166,7 +152,7 @@ all!
+
+
-Wed Oct 3 02:07:59 BRT 2007
+Mon Apr 16 21:58:56 HKT 2012
Installation
-Directory structure
@@ -64,14 +56,19 @@ scheme will likely already have been answered.
-<LDIR>/compat-5.1.lua <LDIR>/ltn12.lua <LDIR>/socket.lua <CDIR>/socket/core.dll @@ -88,33 +85,6 @@ distribution directory structure: would be replaced by core.so. -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 compat-5.1.lua module at startup:
- --LUA_INIT=@<LDIR>/compat-5.1.lua -- --This is only need for Lua 5.0! Lua 5.1 comes with -the package system built in, of course. -
- --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. -
- --LUA_PATH=<LDIR>/?.lua;?.lua -LUA_CPATH=<CDIR>/?.dll;?.dll -- -Again, naturally, on Unix systems the shared library extension would be -.so instead of .dll.
-Using LuaSocket
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 require function to gain access to whatever module you need:
-Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio +Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio > socket = require("socket") > print(socket._VERSION) ---> LuaSocket 2.0.2 +--> LuaSocket 2.1.1-rc1Each module loads their dependencies automatically, so you only need to load the modules you directly depend upon:
-Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio +Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio > http = require("socket.http") -> print(http.request("http://www.cs.princeton.edu/~diego/professional/luasocket")) +> print(http.request("http://www.impa.br/~diego/software/luasocket")) --> homepage gets dumped to terminal@@ -153,7 +123,7 @@ Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-RioLast modified by Diego Nehab on
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">
-Thu Apr 20 00:25:30 EDT 2006 +Mon Apr 16 21:01:42 HKT 2012DNS (in socket)@@ -194,6 +197,7 @@ Support, Manual"> UDP (in socket)+getaddrinfo, gethostname, tohostname, toip. @@ -155,9 +156,11 @@ Support, Manual"> sleep, _SETSIZE, source, -tcp, +tcp, +tcp6, try, -udp, +udp, +udp6, _VERSION.close, +getoption, getpeername, getsockname, receive, 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 @@ -TCP
+TCP
-+
socket.tcp()
-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 listen (after a call to bind) or into a client object with @@ -58,9 +58,34 @@ In case of success, a new master object is returned. In case of error, nil is returned, followed by an error message.
+ + ++socket.tcp6() +
+ ++Creates and returns an IPv6 TCP master object. A master object can +be transformed into a server object with the method +listen (after a call to bind) or into a client object with +the method connect. The only other +method supported by a master object is the +close method.
+ ++In case of success, a new master object is returned. In case of error, +nil is returned, followed by an error message. +
+ ++Note: The TCP object returned will have the option +"ipv6-v6only" set to true. +
+ -+
server:accept()
@@ -87,7 +112,7 @@ might block until another client shows up. -+
master:bind(address, port)
@@ -116,7 +141,7 @@ is available and is a shortcut for the creation of server sockets. -+
master:close()
client:close()
server:close() @@ -139,7 +164,7 @@ automatically closed before destruction, though. -+
master:connect(address, port)
@@ -180,9 +205,18 @@ href=socket.html#select>socket.select with the socket in the established. ++Note: Starting with LuaSocket 2.1, the host name resolution +depends on whether the socket was created by socket.tcp or socket.tcp6. Addresses from +the appropriate family are tried in succession until the +first success or until the last failure. +
+ -+
client:getpeername()
@@ -202,7 +236,7 @@ Note: It makes no sense to call this method on server objects. -+
master:getsockname()
client:getsockname()
server:getsockname() @@ -219,7 +253,7 @@ the port. In case of error, the method returns nil. -+
master:getstats()
client:getstats()
server:getstats()
@@ -237,7 +271,7 @@ and the age of the socket object in seconds. -+
master:listen(backlog)
@@ -265,7 +299,7 @@ method returns nil followed by an error message. -+
client:receive([pattern [, prefix]])
@@ -316,7 +350,7 @@ too. -+
client:send(data [, i [, j]])
@@ -354,7 +388,7 @@ instead of calling the method several times. -+
client:setoption(option [, value])
@@ -392,8 +426,11 @@ used in validating addresses supplied in a call to bind should allow reuse of local addresses;
server:setoption(option [, value])'tcp-nodelay': Setting this option to true -disables the Nagle's algorithm for the connection. +disables the Nagle's algorithm for the connection; + 'ipv6-v6only': +Setting this option to true restricts an inet6 socket to +sending and receiving only IPv6 packets. @@ -407,7 +444,7 @@ Note: The descriptions above come from the man pages. -
+
client:getoption(option)
@@ -433,13 +470,9 @@ The method returns the option value in case of success, or nil followed by an error message otherwise. -
server:getoption(option)-Note: The descriptions above come from the man pages. -
- -+
master:setstats(received, sent, age)
client:setstats(received, sent, age)
server:setstats(received, sent, age)
@@ -462,7 +495,7 @@ The method returns 1 in case of success and nil otherwise. -+
master:settimeout(value [, mode])
client:settimeout(value [, mode])
server:settimeout(value [, mode]) @@ -519,7 +552,7 @@ contained verbs making their imperative nature obvious. -+
client:shutdown(mode)
@@ -543,7 +576,7 @@ This function returns 1. -
+
master:dirty()
client:dirty()
server:dirty() @@ -563,7 +596,7 @@ Note: This is an internal method, any use is unlikely to be portable. -+
master:getfd()
client:getfd()
server:getfd() @@ -583,7 +616,7 @@ Note: This is an internal method, any use is unlikely to be portable. -+
master:setfd(fd)
client:setfd(fd)
server:setfd(fd) 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 @@ -UDP
+UDP
@@ -46,10 +46,12 @@ socket.udp()-Creates and returns an unconnected UDP object. Unconnected objects support the +Creates and returns an unconnected IPv4 UDP object. +Unconnected objects support the sendto, receive, receivefrom, +getoption, getsockname, setoption, settimeout, @@ -66,6 +68,44 @@ returned. In case of error, nil is returned, followed by an error message.
+ + ++socket.udp6() +
+ ++Creates and returns an unconnected IPv6 UDP object. +Unconnected objects support the +sendto, +receive, +receivefrom, +getoption, +getsockname, +setoption, +settimeout, +setpeername, +setsockname, and +close. +The setpeername +is used to connect the object. +
+ ++In case of success, a new unconnected UDP object +returned. In case of error, nil is returned, followed by +an error message. +
+ ++Note: The TCP object returned will have the option +"ipv6-v6only" set to true. +
+ + + + +@@ -177,6 +217,40 @@ address and port as extra return values (and is therefore slightly less efficient).
+ + ++connected:getoption()
+ +
+unconnected:getoption() ++Gets an option value from the UDP object. +See setoption for +description of the option names and values. +
+ +Option is a string with the option name. +
+
+ + +- 'dontroute' +
- 'broadcast' +
- 'reuseaddr' +
- 'reuseport' +
- 'ip-multicast-loop' +
- 'ipv6-v6only' +
- 'ip-multicast-if' +
- 'ip-multicast-ttl' +
- 'ip-add-membership' +
- 'ip-drop-membership' +
+The method returns the option value in case of +success, or +nil followed by an error message otherwise. +
+@@ -284,6 +358,15 @@ is recommended when the same peer is used for several transmissions and can result in up to 30% performance gains.
++Note: Starting with LuaSocket 2.1, the host name resolution +depends on whether the socket was created by socket.udp or socket.udp6. Addresses from +the appropriate family are tried in succession until the +first success or until the last failure. +
+@@ -332,23 +415,57 @@ only modify an option if you are sure you need it.
name, and value depends on the option being set: --
+- 'dontroute': Setting this option to true -indicates that outgoing messages should bypass the standard routing -facilities;
-- 'broadcast': Setting this option to true -requests permission to send broadcast datagrams on the -socket.
-+
- 'dontroute': Indicates that outgoing +messages should bypass the standard routing facilities. +Receives a boolean value; +
- 'broadcast': Requests permission to send +broadcast datagrams on the socket. +Receives a boolean value; +
- 'reuseaddr': Indicates that the rules used in +validating addresses supplied in a bind() call +should allow reuse of local addresses. +Receives a boolean value; +
- 'reuseport': Allows completely duplicate +bindings by multiple processes if they all set +'reuseport' before binding the port. +Receives a boolean value; +
- 'ip-multicast-loop': +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; +
- 'ipv6-v6only': +Specifies whether to restrict inet6 sockets to +sending and receiving only IPv6 packets. +Receive a boolean value; +
- 'ip-multicast-if': +Sets the interface over which outgoing multicast datagrams +are sent. +Receives an IP address; +
- 'ip-multicast-ttl': +Sets the Time To Live in the IP header for outgoing +multicast datagrams. +Receives a number; +
- 'ip-add-membership': +Joins the multicast group specified. +Receives a table with fields +multiaddr and interface, each containing an +IP address; +
- 'ip-drop-membership': Leaves the multicast +group specified. +Receives a table with fields +multiaddr and interface, each containing an +IP address. +
The method returns 1 in case of success, or nil followed by an error message otherwise.
--Note: The descriptions above come from the man -pages. +
+Note: The descriptions above come from the man pages.
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 @@ -URL
+URL
The url namespace provides functions to parse, protect, @@ -69,7 +69,7 @@ An URL is defined by the following grammar: -
+
url.absolute(base, relative)
@@ -125,7 +125,7 @@ g;x?y#s = http://a/b/c/g;x?y#s -+
url.build(parsed_url)
@@ -146,7 +146,7 @@ The function returns a string with the built URL. -+
url.build_path(segments, unsafe)
@@ -200,7 +200,7 @@ code = url.escape("/#?;") -+
url.parse(url, default)
@@ -265,7 +265,7 @@ parsed_url = url.parse("ftp://root:passwd@unsafe.org/pub/virus.exe;type=i") -+
url.parse_path(path)
diff --git a/makefile.dist b/makefile.dist index e4f8da8..fbd6681 100644 --- a/makefile.dist +++ b/makefile.dist @@ -1,7 +1,7 @@ #-------------------------------------------------------------------------- # Distribution makefile #-------------------------------------------------------------------------- -DIST = luasocket-2.0.3 +DIST = luasocket-2.1.1-rc1 TEST = \ 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 @@ /*-------------------------------------------------------------------------*\ * Current socket library version \*-------------------------------------------------------------------------*/ -#define LUASOCKET_VERSION "LuaSocket 2.1.1" -#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2011 Diego Nehab" +#define LUASOCKET_VERSION "LuaSocket 2.1.1-rc1" +#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2012 Diego Nehab" #define LUASOCKET_AUTHORS "Diego Nehab" /*-------------------------------------------------------------------------*\ diff --git a/src/mime.h b/src/mime.h index 37f370f..150e7ad 100644 --- a/src/mime.h +++ b/src/mime.h @@ -13,8 +13,8 @@ /*-------------------------------------------------------------------------*\ * Current MIME library version \*-------------------------------------------------------------------------*/ -#define MIME_VERSION "MIME 1.0.3" -#define MIME_COPYRIGHT "Copyright (C) 2004-2009 Diego Nehab" +#define MIME_VERSION "MIME 1.0.3-rc1" +#define MIME_COPYRIGHT "Copyright (C) 2004-2012 Diego Nehab" #define MIME_AUTHORS "Diego Nehab" /*-------------------------------------------------------------------------*\