diff --git a/doc/dns.html b/doc/dns.html index c4a0472..56ce3ba 100644 --- a/doc/dns.html +++ b/doc/dns.html @@ -1,4 +1,4 @@ - @@ -13,22 +13,22 @@ -
-
+
+
| Network support for the Lua language
+ | Network support for the Lua language
| |
+
home · download · installation · introduction · -reference +reference
-IPv4 name resolution functions -dns.toip +IPv4 name resolution functions +dns.toip and -dns.tohostname -return all information obtained from +dns.tohostname +return all information obtained from the resolver in a table of the form:
@@ -60,10 +60,10 @@ Note that the alias list can be empty.-The more general name resolution function -dns.getaddrinfo, which +The more general name resolution function +dns.getaddrinfo, which supports both IPv6 and IPv4, -returns all information obtained from +returns all information obtained from the resolver in a table of the form:
@@ -88,82 +88,82 @@ addresses, and "inet6" for IPv6 addresses. -+
socket.dns.getaddrinfo(address)
--Converts from host name to address. +
+Converts from host name to address.
--Address can be an IPv4 or IPv6 address or host name. +
+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. +followed by an error message.
-+
socket.dns.gethostname()
--Returns the standard host name for the machine as a string. +
+Returns the standard host name for the machine as a string.
-+
socket.dns.tohostname(address)
-+
Converts from IPv4 address to host name.
--Address can be an IP address or host name. +
+Address can be an IP address or host name.
-+
The function returns a string with the canonic host name of the given address, followed by a table with all information returned by the resolver. In case of error, the function returns nil -followed by an error message. +followed by an error message.
-+
socket.dns.toip(address)
-+
Converts from host name to IPv4 address.
--Address can be an IP address or host name. +
+Address can be an IP address or host name.
-+
Returns a string with the first IP address found for address, followed by a table with all information returned by the resolver. In case of error, the function returns nil followed by an error -message. +message.
-+
home · download · installation · diff --git a/doc/ftp.html b/doc/ftp.html index 091c88f..7f7da2e 100644 --- a/doc/ftp.html +++ b/doc/ftp.html @@ -1,5 +1,5 @@ - +
@@ -13,22 +13,22 @@ -
-
+
+
| Network support for the Lua language
+ | Network support for the Lua language
| |
+
home · download · installation · introduction · -reference +reference
FTP (File Transfer Protocol) is a protocol used to transfer files @@ -50,28 +50,28 @@ High level functions are provided supporting the most common operations. These high level functions are implemented on top of a lower level interface. Using the low-level interface, users can easily create their own functions to access any operation supported by the FTP -protocol. For that, check the implementation. +protocol. For that, check the implementation.
-To really benefit from this module, a good understanding of +To really benefit from this module, a good understanding of -LTN012, Filters sources and sinks is necessary. +LTN012, Filters sources and sinks is necessary.
-+
To obtain the ftp namespace, run:
-+-- loads the FTP module and any libraries it requires local ftp = require("socket.ftp")URLs MUST conform to -RFC 1738, -that is, an URL is a string in the form: +RFC 1738, +that is, an URL is a string in the form:
@@ -81,19 +81,19 @@ that is, an URL is a string in the form:The following constants in the namespace can be set to control the default behavior of -the FTP module: +the FTP module:
-
-- PASSWORD: default anonymous password. -
- TIMEOUT: sets the timeout for all I/O operations; -
- USER: default anonymous user; +
- PASSWORD: default anonymous password.
+- TIMEOUT: sets the timeout for all I/O operations;
+- USER: default anonymous user;
+
ftp.get(url)
-
ftp.get{
host = string,
@@ -109,19 +109,19 @@ ftp.get{
}+
The get function has two forms. The simple form has fixed functionality: it downloads the contents of a URL and returns it as a string. The generic form allows a lot more control, as explained below.
-+
If the argument of the get function is a table, the function -expects at least the fields host, sink, and one of +expects at least the fields host, sink, and one of argument or path (argument takes precedence). Host is the server to connect to. Sink is -the simple +the simple LTN12 sink that will receive the downloaded data. Argument or path give the target path to the resource in the server. The @@ -129,28 +129,28 @@ optional arguments are the following:
-
- user, password: User name and password used for -authentication. Defaults to "ftp:anonymous@anonymous.org"; +authentication. Defaults to "ftp:anonymous@anonymous.org";
- command: The FTP command used to obtain data. Defaults to -"retr", but see example below; -
- port: The port to used for the control connection. Defaults to 21; +"retr", but see example below;
+- port: The port to used for the control connection. Defaults to 21;
- type: The transfer mode. Can take values "i" or -"a". Defaults to whatever is the server default; -
- step: +"a". Defaults to whatever is the server default;
+- step: LTN12 pump step function used to pass data from the -server to the sink. Defaults to the LTN12 pump.step function; +server to the sink. Defaults to the LTN12 pump.step function;
- create: An optional function to be used instead of -socket.tcp when the communications socket is created. +socket.tcp when the communications socket is created.
+
If successful, the simple version returns the URL contents as a string, and the generic function returns 1. In case of error, both functions return nil and an error message describing the -error. +error.
-+-- load the ftp support local ftp = require("socket.ftp") @@ -159,7 +159,7 @@ local ftp = require("socket.ftp") f, e = ftp.get("ftp://ftp.tecgraf.puc-rio.br/pub/lua/lua.tar.gz;type=i")-+-- load needed modules local ftp = require("socket.ftp") local ltn12 = require("ltn12") @@ -178,7 +178,7 @@ end -+
ftp.put(url, content)
-
ftp.put{
host = string,
@@ -194,57 +194,57 @@ ftp.put{
}+
The put function has two forms. The simple form has fixed functionality: it uploads a string of content into a URL. The generic form -allows a lot more control, as explained below. +allows a lot more control, as explained below.
-+
If the argument of the put function is a table, the function -expects at least the fields host, source, and one of +expects at least the fields host, source, and one of argument or path (argument takes precedence). Host is the server to connect to. Source is -the simple -LTN12 -source that will provide the contents to be uploaded. +the simple +LTN12 +source that will provide the contents to be uploaded. Argument or path give the target path to the resource in the server. The optional arguments are the following:
-
- user, password: User name and password used for -authentication. Defaults to "ftp:anonymous@anonymous.org"; +authentication. Defaults to "ftp:anonymous@anonymous.org";
- command: The FTP command used to send data. Defaults to -"stor", but see example below; -
- port: The port to used for the control connection. Defaults to 21; +"stor", but see example below;
+- port: The port to used for the control connection. Defaults to 21;
- type: The transfer mode. Can take values "i" or -"a". Defaults to whatever is the server default; -
- step: -LTN12 +"a". Defaults to whatever is the server default;
+- step: +LTN12 pump step function used to pass data from the -server to the sink. Defaults to the LTN12 pump.step function; +server to the sink. Defaults to the LTN12 pump.step function;
- create: An optional function to be used instead of -socket.tcp when the communications socket is created. +socket.tcp when the communications socket is created.
+
Both functions return 1 if successful, or nil and an error message describing the reason for failure.
-+-- load the ftp support local ftp = require("socket.ftp") -- Log as user "fulano" on server "ftp.example.com", --- using password "silva", and store a file "README" with contents +-- using password "silva", and store a file "README" with contents -- "wrong password, of course" -f, e = ftp.put("ftp://fulano:silva@ftp.example.com/README", +f, e = ftp.put("ftp://fulano:silva@ftp.example.com/README", "wrong password, of course")-+-- load the ftp support local ftp = require("socket.ftp") local ltn12 = require("ltn12") @@ -253,7 +253,7 @@ local ltn12 = require("ltn12") -- using password "silva", and append to the remote file "LOG", sending the -- contents of the local file "LOCAL-LOG" f, e = ftp.put{ - host = "ftp.example.com", + host = "ftp.example.com", user = "fulano", password = "silva", command = "appe", @@ -265,15 +265,15 @@ f, e = ftp.put{ -+
- +
home · download · installation · introduction · -reference +reference
diff --git a/doc/http.html b/doc/http.html index 78f785a..52b8a30 100644 --- a/doc/http.html +++ b/doc/http.html @@ -1,10 +1,10 @@ - - +
LuaSocket: HTTP support @@ -13,22 +13,22 @@ -+
-
-- + - + Network support for the Lua language + Network support for the Lua language +
home · download · introduction · introduction · -reference +reference
@@ -36,12 +36,12 @@ -HTTP
+HTTP
HTTP (Hyper Text Transfer Protocol) is the protocol used to exchange information between web-browsers and servers. The http -namespace offers full support for the client side of the HTTP +namespace offers full support for the client side of the HTTP protocol (i.e., the facilities that would be used by a web-browser implementation). The implementation conforms to the HTTP/1.1 standard, @@ -50,16 +50,16 @@ implementation conforms to the HTTP/1.1 standard,
The module exports functions that provide HTTP functionality in different -levels of abstraction. From the simple +levels of abstraction. From the simple string oriented requests, through generic LTN12 based, down to even lower-level if you bother to look through the source code.
-+
To obtain the http namespace, run:
-+-- loads the HTTP module and any libraries it requires local http = require("socket.http")@@ -67,12 +67,12 @@ local http = require("socket.http")URLs must conform to RFC 1738, -that is, an URL is a string in the form: +that is, an URL is a string in the form:
@@ -97,34 +97,34 @@ headers = {-[http://][<user>[:<password>]@]<host>[:<port>][/<path>] +[http://][<user>[:<password>]@]<host>[:<port>][/<path>]
Field names are case insensitive (as specified by the standard) and all functions work with lowercase field names (but see -socket.headers.canonic). +socket.headers.canonic). Field values are left unmodified.
-+
Note: MIME headers are independent of order. Therefore, there is no problem -in representing them in a Lua table. +in representing them in a Lua table.
The following constants can be set to control the default behavior of -the HTTP module: +the HTTP module:
-
-- PROXY: default proxy used for connections; -
- TIMEOUT: sets the timeout for all I/O operations; -
- USERAGENT: default user agent reported to server. +
- PROXY: default proxy used for connections;
+- TIMEOUT: sets the timeout for all I/O operations;
+- USERAGENT: default user agent reported to server.
+
Note: These constants are global. Changing them will also change the behavior other code that might be using LuaSocket.
-+
http.request(url [, body])
-
http.request{
url = string,
@@ -140,26 +140,26 @@ http.request{
}-The request function has two forms. The simple form downloads -a URL using the GET or POST method and is based -on strings. The generic form performs any HTTP method and is -LTN12 based. +
+The request function has two forms. The simple form downloads +a URL using the GET or POST method and is based +on strings. The generic form performs any HTTP method and is +LTN12 based.
-+
If the first argument of the request function is a string, it should be an url. In that case, if a body is provided as a string, the function will perform a POST method in the url. Otherwise, it performs a GET in the -url +url
--If the first argument is instead a table, the most important fields are +
+If the first argument is instead a table, the most important fields are the url and the simple -LTN12 -sink that will receive the downloaded content. +LTN12 +sink that will receive the downloaded content. Any part of the url can be overridden by including the appropriate field in the request table. If authentication information is provided, the function @@ -169,49 +169,51 @@ function discards the downloaded data. The optional parameters are the following:
-
-- method: The HTTP request method. Defaults to "GET"; -
- headers: Any additional HTTP headers to send with the request; -
- source: simple -LTN12 +
- method: The HTTP request method. Defaults to "GET";
+- headers: Any additional HTTP headers to send with the request;
+- source: simple +LTN12 source to provide the request body. If there is a body, you need to provide an appropriate "content-length" request header field, or the function will attempt to send the body as -"chunked" (something few servers support). Defaults to the empty source; -
- step: -LTN12 -pump step function used to move data. -Defaults to the LTN12 pump.step function. -
- proxy: The URL of a proxy server to use. Defaults to no proxy; -
- redirect: Set to false to prevent the -function from automatically following 301 or 302 server redirect messages; +"chunked" (something few servers support). Defaults to the empty source;
+- step: +LTN12 +pump step function used to move data. +Defaults to the LTN12 pump.step function.
+- proxy: The URL of a proxy server to use. Defaults to no proxy;
+- redirect: Set to false to prevent the +function from automatically following 301 or 302 server redirect messages;
- create: An optional function to be used instead of -socket.tcp when the communications socket is created. -
- maxredirects: An optional number specifying the maximum number of redirects to follow. Defaults to 5 if not specified. A boolean false value means no maximum (unlimited). +socket.tcp when the communications socket is created.
+- maxredirects: An optional number specifying the maximum number of + redirects to follow. Defaults to 5 if not specified. A boolean + false value means no maximum (unlimited).
+
In case of failure, the function returns nil followed by an -error message. If successful, the simple form returns the response +error message. If successful, the simple form returns the response body as a string, followed by the response status code, the response headers and the response status line. The generic function returns the same information, except the first return value is just the number 1 (the body goes to the sink).
--Even when the server fails to provide the contents of the requested URL (URL not found, for example), +
+Even when the server fails to provide the contents of the requested URL (URL not found, for example), it usually returns a message body (a web page informing the URL was not found or some other useless page). To make sure the operation was successful, check the returned status code. For a list of the possible values and their meanings, refer to RFC 2616. +href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616.
-+
Here are a few examples with the simple interface:
-+-- load the http module local io = require("io") local http = require("socket.http") @@ -219,15 +221,15 @@ local ltn12 = require("ltn12") -- connect to server "www.cs.princeton.edu" and retrieves this manual -- file from "~diego/professional/luasocket/http.html" and print it to stdout -http.request{ - url = "http://www.cs.princeton.edu/~diego/professional/luasocket/http.html", +http.request{ + url = "http://www.cs.princeton.edu/~diego/professional/luasocket/http.html", sink = ltn12.sink.file(io.stdout) } -- connect to server "www.example.com" and tries to retrieve -- "/private/index.html". Fails because authentication is needed. b, c, h = http.request("http://www.example.com/private/index.html") --- b returns some useless page telling about the denied access, +-- b returns some useless page telling about the denied access, -- h returns authentication information -- and c returns with value 401 (Authentication Required) @@ -237,11 +239,11 @@ r, e = http.request("http://wrong.host/") -- r is nil, and e returns with value "host not found"-+
And here is an example using the generic interface:
-+-- load the http module http = require("socket.http") @@ -263,7 +265,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 @@ -271,21 +273,21 @@ 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 -download and return status "401 Authentication Required". +download and return status "401 Authentication Required".
-+
The HTTP/1.1 standard defines two authentication methods: the Basic Authentication Scheme and the Digest Authentication Scheme, both explained in detail in RFC 2068.
-The Basic Authentication Scheme sends +
The Basic Authentication Scheme sends <user> and <password> unencrypted to the server and is therefore considered unsafe. Unfortunately, by the time of this implementation, @@ -294,7 +296,7 @@ Therefore, this is the method used by the toolkit whenever authentication is required.
-+-- load required modules http = require("socket.http") mime = require("mime") @@ -314,15 +316,15 @@ r, c = http.request { -+
- +
home · download · installation · introduction · -reference +reference
diff --git a/doc/index.html b/doc/index.html index 7d81b41..e92b4d4 100644 --- a/doc/index.html +++ b/doc/index.html @@ -1,4 +1,4 @@ - @@ -13,22 +13,22 @@ -
+
-
-- + - + Network support for the Lua language + Network support for the Lua language +
home · download · installation · introduction · -reference +reference
@@ -36,13 +36,13 @@ -What is LuaSocket?
+What is LuaSocket?
LuaSocket is a Lua extension library that is composed by two parts: a C core that provides support for the TCP and UDP transport layers, and a set of Lua modules that add support for -functionality commonly needed by applications that deal with the Internet. +functionality commonly needed by applications that deal with the Internet.
@@ -52,43 +52,43 @@ properly initialized by the interpreter in use. The code has been tested and runs well on several Windows and UNIX platforms.
-Among the support modules, the most commonly used implement the -SMTP -(sending e-mails), -HTTP -(WWW access) and -FTP +Among the support modules, the most commonly used implement the +SMTP +(sending e-mails), +HTTP +(WWW access) and +FTP (uploading and downloading files) client protocols. These provide a very natural and generic interface to the -functionality defined by each protocol. -In addition, you will find that the -MIME (common encodings), -URL -(anything you could possible want to do with one) and -LTN12 -(filters, sinks, sources and pumps) modules can be very handy. +functionality defined by each protocol. +In addition, you will find that the +MIME (common encodings), +URL +(anything you could possible want to do with one) and +LTN12 +(filters, sinks, sources and pumps) modules can be very handy.
-The library is available under the same +The library is available under the same terms and conditions as the Lua language, the MIT license. The idea is -that if you can use Lua in a project, you should also be able to use +that if you can use Lua in a project, you should also be able to use LuaSocket.
Copyright © 1999-2013 Diego Nehab. All rights reserved.
-
-Author: Diego Nehab +Author: Diego NehabDownload
+Download
-LuaSocket version 3.0-rc1 is now available for download! -It is compatible with Lua 5.1 and 5.2, and has +LuaSocket version 3.0-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.
@@ -96,19 +96,19 @@ are it works well on most UNIX distributions and Windows flavors.The current version of the library can be found at the LuaSocket -project page on GitHub. Besides the full C and Lua source code -for the library, the distribution contains several examples, +project page on 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 installation section of the +href="installation.html">installation section of the manual to find out how to properly install the library.
-Special thanks
+Special thanks
This marks the first release of LuaSocket that @@ -118,85 +118,85 @@ convinced me it was time for a release including IPv6 and Lua 5.2 support. It was more work than we anticipated. Special thanks to Sam Roberts, Florian Zeitz, and Paul Aurich, Liam Devine, Alexey Melnichuk, and everybody else -that has helped bring this library back to life. +that has helped bring this library back to life.
-What's New
+What's New
Main changes for LuaSocket 3.0-rc1 are IPv6 support -and Lua 5.2 compatibility. +and Lua 5.2 compatibility.
-
-- Added: Compatible with Lua 5.2 +
- Added: Compatible with Lua 5.2
-
- Note that unless you define LUA_COMPAT_MODULE, -package tables will not be exported as globals! +package tables will not be exported as globals!
- Added: IPv6 support; +
- Added: IPv6 support;
-
-- Socket.connect and socket.bind support IPv6 addresses; +
- Socket.connect and socket.bind support IPv6 addresses;
- Getpeername and getsockname support -IPv6 addresses, and return the socket family as a third value; -
- URL module updated to support IPv6 host names; -
- New socket.tcp6 and socket.udp6 functions; -
- New socket.dns.getaddrinfo and - socket.dns.getnameinfo functions; +IPv6 addresses, and return the socket family as a third value;
+- URL module updated to support IPv6 host names;
+- New socket.tcp6 and socket.udp6 functions;
+- New socket.dns.getaddrinfo and + socket.dns.getnameinfo functions;
- Added: getoption method; -
- Fixed: url.unescape was returning additional values; -
- Fixed: mime.qp, mime.unqp, +
- Added: getoption method;
+- Fixed: url.unescape was returning additional values;
+- Fixed: mime.qp, mime.unqp, mime.b64, and mime.unb64 could - mistaking their own stack slots for functions arguments; -
- Fixed: Receiving zero-length datagram is now possible; -
- Improved: Hidden all internal library symbols; -
- Improved: Better error messages; -
- Improved: Better documentation of socket options. + mistaking their own stack slots for functions arguments;
+- Fixed: Receiving zero-length datagram is now possible;
+- Improved: Hidden all internal library symbols;
+- Improved: Better error messages;
+- Improved: Better documentation of socket options.
- Fixed: manual sample of HTTP authentication now uses correct - "authorization" header (Alexandre Ittner); -
- Fixed: failure on bind() was destroying the socket (Sam Roberts); + "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); + bytes requested (M Joonas Pihlaja);
- Fixed: multicast didn't work on Windows, or anywhere - else for that matter (Herbert Leuwer, Adrian Sietsma); + else for that matter (Herbert Leuwer, Adrian Sietsma);
- Fixed: select() now reports an error when called with more - sockets than FD_SETSIZE (Lorenzo Leonini); + sockets than FD_SETSIZE (Lorenzo Leonini);
- Fixed: manual links to home.html changed to index.html -(Robert Hahn); +(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); + 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); + block forever, wasting CPU. Now it returns immediately (MPB);
- Improved: FTP commands are now sent in upper case to - help buggy servers (Anders Eurenius); + 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). + 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).
Old Versions
+Old Versions
All previous versions of the LuaSocket library can be downloaded here. Although these versions are no longer supported, they are -still available for those that have compatibility issues. +still available for those that have compatibility issues.
-+
- +
download · installation · introduction · diff --git a/doc/ltn12.html b/doc/ltn12.html index ee2502f..fe3e3a0 100644 --- a/doc/ltn12.html +++ b/doc/ltn12.html @@ -1,4 +1,4 @@ - @@ -14,22 +14,22 @@ Pump, Support, Library"> -
+
-
-- + - + Network support for the Lua language + Network support for the Lua language +
home · download · installation · introduction · -reference +reference
@@ -37,7 +37,7 @@ Pump, Support, Library"> -LTN12
+LTN12
The ltn12 namespace implements the ideas described in @@ -46,11 +46,11 @@ functions. Please refer to the LTN for a deeper explanation of the functionality provided by this module.
-+
To obtain the ltn12 namespace, run:
-+-- loads the LTN21 module local ltn12 = require("ltn12")@@ -61,32 +61,32 @@ local ltn12 = require("ltn12") --ltn12.filter.chain(filter1, filter2 +
+ltn12.filter.chain(filter1, filter2 [, ... filterN])
-+
Returns a filter that passes all data it receives through each of a -series of given filters. +series of given filters.
-+
Filter1 to filterN are simple -filters. +filters.
-+
The function returns the chained filter.
-+
The nesting of filters can be arbitrary. For instance, the useless filter below doesn't do anything but return the data that was passed to it, unaltered.
-+-- load required modules local ltn12 = require("ltn12") local mime = require("mime") @@ -102,26 +102,26 @@ id = ltn12.filter.chain( -+
ltn12.filter.cycle(low [, ctx, extra])
-+
Returns a high-level filter that cycles though a low-level filter by -passing it each chunk and updating a context between calls. +passing it each chunk and updating a context between calls.
--Low is the low-level filter to be cycled, +
+Low is the low-level filter to be cycled, ctx is the initial context and extra is any extra argument the low-level filter might take.
--The function returns the high-level filter. +
+The function returns the high-level filter.
-+-- load the ltn12 module local ltn12 = require("ltn12") @@ -137,15 +137,15 @@ end -+
ltn12.pump.all(source, sink)
--Pumps all data from a source to a sink. +
+Pumps all data from a source to a sink.
-+
If successful, the function returns a value that evaluates to true. In case of error, the function returns a false value, followed by an error message. @@ -153,15 +153,15 @@ of error, the function returns a false value, followed by an err -
+
ltn12.pump.step(source, sink)
--Pumps one chunk of data from a source to a sink. +
+Pumps one chunk of data from a source to a sink.
-+
If successful, the function returns a value that evaluates to true. In case of error, the function returns a false value, followed by an error message. @@ -173,52 +173,52 @@ of error, the function returns a false value, followed by an err -
+
ltn12.sink.chain(filter, sink)
--Creates and returns a new sink that passes data through a filter before sending it to a given sink. +
+Creates and returns a new sink that passes data through a filter before sending it to a given sink.
-+
ltn12.sink.error(message)
-+
Creates and returns a sink that aborts transmission with the error message.
-+
ltn12.sink.file(handle, message)
--Creates a sink that sends data to a file. +
+Creates a sink that sends data to a file.
--Handle is a file handle. If handle is nil, -message should give the reason for failure. +
+Handle is a file handle. If handle is nil, +message should give the reason for failure.
-+
The function returns a sink that sends all data to the given handle and closes the file when done, or a sink that aborts the transmission with the error message
--In the following example, notice how the prototype is designed to +
+In the following example, notice how the prototype is designed to fit nicely with the io.open function.
-+-- load the ltn12 module local ltn12 = require("ltn12") @@ -231,45 +231,45 @@ ltn12.pump.all( -+
ltn12.sink.null()
--Returns a sink that ignores all data it receives. +
+Returns a sink that ignores all data it receives.
-+
ltn12.sink.simplify(sink)
--Creates and returns a simple sink given a fancy sink. +
+Creates and returns a simple sink given a fancy sink.
-+
ltn12.sink.table([table])
-+
Creates a sink that stores all chunks in a table. The chunks can later be efficiently concatenated into a single string.
-+
Table is used to hold the chunks. If -nil, the function creates its own table. +nil, the function creates its own table.
--The function returns the sink and the table used to store the chunks. +
+The function returns the sink and the table used to store the chunks.
-+-- load needed modules local http = require("socket.http") local ltn12 = require("ltn12") @@ -291,89 +291,89 @@ end -+
ltn12.source.cat(source1 [, source2, ..., sourceN])
-+
Creates a new source that produces the concatenation of the data produced -by a number of sources. +by a number of sources.
-+
Source1 to sourceN are the original -sources. +sources.
-+
The function returns the new source.
-+
ltn12.source.chain(source, filter)
--Creates a new source that passes data through a filter -before returning it. +
+Creates a new source that passes data through a filter +before returning it.
-+
The function returns the new source.
-+
ltn12.source.empty()
--Creates and returns an empty source. +
+Creates and returns an empty source.
-+
ltn12.source.error(message)
-+
Creates and returns a source that aborts transmission with the error message.
-+
ltn12.source.file(handle, message)
--Creates a source that produces the contents of a file. +
+Creates a source that produces the contents of a file.
--Handle is a file handle. If handle is nil, -message should give the reason for failure. +
+Handle is a file handle. If handle is nil, +message should give the reason for failure.
--The function returns a source that reads chunks of data from +
+The function returns a source that reads chunks of data from given handle and returns it to the user, closing the file when done, or a source that aborts the transmission with the error message
--In the following example, notice how the prototype is designed to +
+In the following example, notice how the prototype is designed to fit nicely with the io.open function.
-+-- load the ltn12 module local ltn12 = require("ltn12") @@ -386,41 +386,41 @@ ltn12.pump.all( -+
ltn12.source.simplify(source)
--Creates and returns a simple source given a fancy source. +
+Creates and returns a simple source given a fancy source.
-+
ltn12.source.string(string)
-+
Creates and returns a source that produces the contents of a -string, chunk by chunk. +string, chunk by chunk.
-+
ltn12.source.table(table)
-+
Creates and returns a source that produces the numerically-indexed values of a table successively beginning at 1. The source returns nil (end-of-stream) whenever a nil value is produced by the current index, which proceeds forward regardless.
-+
- +
home · download · installation · diff --git a/doc/mime.html b/doc/mime.html index 8cb3507..ff4d8e8 100644 --- a/doc/mime.html +++ b/doc/mime.html @@ -1,10 +1,10 @@ -
- +LuaSocket: MIME module @@ -13,22 +13,22 @@ -+
-
-- + - + Network support for the Lua language + Network support for the Lua language +
home · download · installation · introduction · -reference +reference
@@ -36,14 +36,14 @@ -MIME
+MIME
The mime namespace offers filters that apply and remove common content transfer encodings, such as Base64 and Quoted-Printable. It also provides functions to break text into lines and change the end-of-line convention. -MIME is described mainly in +MIME is described mainly in RFC 2045, 2046, 2047, @@ -52,17 +52,17 @@ MIME is described mainly in
-All functionality provided by the MIME module -follows the ideas presented in +All functionality provided by the MIME module +follows the ideas presented in -LTN012, Filters sources and sinks. +LTN012, Filters sources and sinks.
-+
To obtain the mime namespace, run:
-+-- loads the MIME module and everything it requires local mime = require("mime")@@ -70,60 +70,60 @@ local mime = require("mime") -High-level filters
+High-level filters
-+
mime.decode("base64")
-
mime.decode("quoted-printable")+
Returns a filter that decodes data from a given transfer content encoding.
-+
mime.encode("base64")
-
mime.encode("quoted-printable" [, mode])+
Returns a filter that encodes data according to a given transfer content encoding.
-+
In the Quoted-Printable case, the user can specify whether the data is textual or binary, by passing the mode strings "text" or "binary". Mode defaults to "text".
-+
Although both transfer content encodings specify a limit for the line length, the encoding filters do not break text into lines (for -added flexibility). +added flexibility). Below is a filter that converts binary data to the Base64 transfer content encoding and breaks it into lines of the correct size.
-+base64 = ltn12.filter.chain( mime.encode("base64"), mime.wrap("base64") )-+
Note: Text data has to be converted to canonic form before being encoded.
-+base64 = ltn12.filter.chain( mime.normalize(), mime.encode("base64"), @@ -133,77 +133,77 @@ base64 = ltn12.filter.chain( -+
mime.normalize([marker])
--Converts most common end-of-line markers to a specific given marker. +
+Converts most common end-of-line markers to a specific given marker.
--Marker is the new marker. It defaults to CRLF, the canonic +
+Marker is the new marker. It defaults to CRLF, the canonic end-of-line marker defined by the MIME standard.
--The function returns a filter that performs the conversion. +
+The function returns a filter that performs the conversion.
-+
Note: There is no perfect solution to this problem. Different end-of-line -markers are an evil that will probably plague developers forever. +markers are an evil that will probably plague developers forever. This function, however, will work perfectly for text created with any of -the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF), +the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF), or the DOS (CRLF) conventions. Even if the data has mixed end-of-line -markers, the function will still work well, although it doesn't +markers, the function will still work well, although it doesn't guarantee that the number of empty lines will be correct.
-+
mime.stuff()
-
+
Creates and returns a filter that performs stuffing of SMTP messages.
--Note: The smtp.send function +
+Note: The smtp.send function uses this filter automatically. You don't need to chain it with your -source, or apply it to your message body. +source, or apply it to your message body.
-+
mime.wrap("text" [, length])
-
mime.wrap("base64")
mime.wrap("quoted-printable")-Returns a filter that breaks data into lines. +
+Returns a filter that breaks data into lines.
--The "text" line-wrap filter simply breaks text into lines by -inserting CRLF end-of-line markers at appropriate positions. -Length defaults 76. +
+The "text" line-wrap filter simply breaks text into lines by +inserting CRLF end-of-line markers at appropriate positions. +Length defaults 76. The "base64" line-wrap filter works just like the default -"text" line-wrap filter with default length. +"text" line-wrap filter with default length. The function can also wrap "quoted-printable" lines, taking care not to break lines in the middle of an escaped character. In that case, the line length is fixed at 76.
-+
For example, to create an encoding filter for the Quoted-Printable transfer content encoding of text data, do the following:
-+qp = ltn12.filter.chain( mime.normalize(), mime.encode("quoted-printable"), @@ -211,155 +211,155 @@ qp = ltn12.filter.chain( )-+
Note: To break into lines with a different end-of-line convention, apply -a normalization filter after the line break filter. +a normalization filter after the line break filter.
-Low-level filters
+Low-level filters
-+
A, B = mime.b64(C [, D])
--Low-level filter to perform Base64 encoding. +
+Low-level filter to perform Base64 encoding.
--A is the encoded version of the largest prefix of -C..D -that can be encoded unambiguously. B has the remaining bytes of -C..D, before encoding. -If D is nil, A is padded with -the encoding of the remaining bytes of C. +
+A is the encoded version of the largest prefix of +C..D +that can be encoded unambiguously. B has the remaining bytes of +C..D, before encoding. +If D is nil, A is padded with +the encoding of the remaining bytes of C.
-+
Note: The simplest use of this function is to encode a string into it's Base64 transfer content encoding. Notice the extra parenthesis around the call to mime.b64, to discard the second return value.
-+print((mime.b64("diego:password"))) --> ZGllZ286cGFzc3dvcmQ=-+
A, n = mime.dot(m [, B])
-+
Low-level filter to perform SMTP stuffing and enable transmission of -messages containing the sequence "CRLF.CRLF". +messages containing the sequence "CRLF.CRLF".
-+
A is the stuffed version of B. 'n' gives the number of characters from the sequence CRLF seen in the end of B. 'm' should tell the same, but for the previous chunk.
-Note: The message body is defined to begin with +
Note: The message body is defined to begin with an implicit CRLF. Therefore, to stuff a message correctly, the -first m should have the value 2. +first m should have the value 2.
-+print((string.gsub(mime.dot(2, ".\r\nStuffing the message.\r\n.\r\n."), "\r\n", "\\n"))) --> ..\nStuffing the message.\n..\n..--Note: The smtp.send function -uses this filter automatically. You don't need to -apply it again. +
+Note: The smtp.send function +uses this filter automatically. You don't need to +apply it again.
-+
A, B = mime.eol(C [, D, marker])
--Low-level filter to perform end-of-line marker translation. +
+Low-level filter to perform end-of-line marker translation. For each chunk, the function needs to know if the last character of the previous chunk could be part of an end-of-line marker or not. This is the context the function receives besides the chunk. An updated version of -the context is returned after each new chunk. +the context is returned after each new chunk.
-+
A is the translated version of D. C is the ASCII value of the last character of the previous chunk, if it was a -candidate for line break, or 0 otherwise. +candidate for line break, or 0 otherwise. B is the same as C, but for the current chunk. Marker gives the new end-of-line marker and defaults to CRLF.
-+-- translates the end-of-line marker to UNIX -unix = mime.eol(0, dos, "\n") +unix = mime.eol(0, dos, "\n")-+
A, B = mime.qp(C [, D, marker])
--Low-level filter to perform Quoted-Printable encoding. +
+Low-level filter to perform Quoted-Printable encoding.
--A is the encoded version of the largest prefix of -C..D -that can be encoded unambiguously. B has the remaining bytes of -C..D, before encoding. -If D is nil, A is padded with -the encoding of the remaining bytes of C. -Throughout encoding, occurrences of CRLF are replaced by the +
+A is the encoded version of the largest prefix of +C..D +that can be encoded unambiguously. B has the remaining bytes of +C..D, before encoding. +If D is nil, A is padded with +the encoding of the remaining bytes of C. +Throughout encoding, occurrences of CRLF are replaced by the marker, which itself defaults to CRLF.
-+
Note: The simplest use of this function is to encode a string into it's -Quoted-Printable transfer content encoding. +Quoted-Printable transfer content encoding. Notice the extra parenthesis around the call to mime.qp, to discard the second return value.
--print((mime.qp("maçã"))) ++print((mime.qp("ma��"))) --> ma=E7=E3=-+
A, m = mime.qpwrp(n [, B, length])
--Low-level filter to break Quoted-Printable text into lines. +
+Low-level filter to break Quoted-Printable text into lines.
--A is a copy of B, broken into lines of at most -length bytes (defaults to 76). -'n' should tell how many bytes are left for the first -line of B and 'm' returns the number of bytes -left in the last line of A. +
+A is a copy of B, broken into lines of at most +length bytes (defaults to 76). +'n' should tell how many bytes are left for the first +line of B and 'm' returns the number of bytes +left in the last line of A.
-+
Note: Besides breaking text into lines, this function makes sure the line breaks don't fall in the middle of an escaped character combination. Also, this function only breaks lines that are bigger than length bytes. @@ -367,86 +367,86 @@ this function only breaks lines that are bigger than length bytes. -
+
A, B = mime.unb64(C [, D])
--Low-level filter to perform Base64 decoding. +
+Low-level filter to perform Base64 decoding.
--A is the decoded version of the largest prefix of -C..D -that can be decoded unambiguously. B has the remaining bytes of -C..D, before decoding. +
+A is the decoded version of the largest prefix of +C..D +that can be decoded unambiguously. B has the remaining bytes of +C..D, before decoding. If D is nil, A is the empty string -and B returns whatever couldn't be decoded. +and B returns whatever couldn't be decoded.
-+
Note: The simplest use of this function is to decode a string from it's -Base64 transfer content encoding. +Base64 transfer content encoding. Notice the extra parenthesis around the call to mime.unqp, to discard the second return value.
-+print((mime.unb64("ZGllZ286cGFzc3dvcmQ="))) --> diego:password-+
A, B = mime.unqp(C [, D])
-+
Low-level filter to remove the Quoted-Printable transfer content encoding -from data. +from data.
--A is the decoded version of the largest prefix of -C..D -that can be decoded unambiguously. B has the remaining bytes of -C..D, before decoding. -If D is nil, A is augmented with -the encoding of the remaining bytes of C. +
+A is the decoded version of the largest prefix of +C..D +that can be decoded unambiguously. B has the remaining bytes of +C..D, before decoding. +If D is nil, A is augmented with +the encoding of the remaining bytes of C.
-+
Note: The simplest use of this function is to decode a string from it's -Quoted-Printable transfer content encoding. +Quoted-Printable transfer content encoding. Notice the extra parenthesis around the call to mime.unqp, to discard the second return value.
-+print((mime.qp("ma=E7=E3="))) ---> maçã +--> ma��-+
A, m = mime.wrp(n [, B, length])
--Low-level filter to break text into lines with CRLF marker. -Text is assumed to be in the normalize form. +
+Low-level filter to break text into lines with CRLF marker. +Text is assumed to be in the normalize form.
--A is a copy of B, broken into lines of at most -length bytes (defaults to 76). -'n' should tell how many bytes are left for the first -line of B and 'm' returns the number of bytes -left in the last line of A. +
+A is a copy of B, broken into lines of at most +length bytes (defaults to 76). +'n' should tell how many bytes are left for the first +line of B and 'm' returns the number of bytes +left in the last line of A.
--Note: This function only breaks lines that are bigger than +
+Note: This function only breaks lines that are bigger than length bytes. The resulting line length does not include the CRLF marker.
@@ -454,10 +454,10 @@ marker. -+
- +
home · download · installation · diff --git a/doc/reference.html b/doc/reference.html index 163a8a2..2bc5f78 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -1,11 +1,11 @@ -
+Support, Manual">LuaSocket: Index to reference manual @@ -14,22 +14,22 @@ Support, Manual"> -+
-
-- + - + Network support for the Lua language + Network support for the Lua language +
home · download · installation · introduction · -reference +reference
@@ -92,7 +92,7 @@ Support, Manual"> table.-source: +source: cat, chain, empty, @@ -238,10 +238,10 @@ Support, Manual"> -+
- +
home · download · installation · diff --git a/doc/smtp.html b/doc/smtp.html index 600ec37..787d0b1 100644 --- a/doc/smtp.html +++ b/doc/smtp.html @@ -1,11 +1,11 @@ -
+Library, Support">LuaSocket: SMTP support @@ -14,22 +14,22 @@ Library, Support"> -+
-
-- + - + Network support for the Lua language + Network support for the Lua language +
home · download · installation · introduction · -reference +reference
@@ -37,14 +37,14 @@ Library, Support"> -SMTP
+SMTP
The smtp namespace provides functionality to send e-mail -messages. The high-level API consists of two functions: one to +messages. The high-level API consists of two functions: one to define an e-mail message, and another to actually send the message. Although almost all users will find that these functions provide more than enough functionality, the underlying implementation allows for even more -control (if you bother to read the code). +control (if you bother to read the code).
The implementation conforms to the Simple Mail Transfer Protocol, @@ -54,19 +54,19 @@ href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822, which governs the Internet Message Format. Multipart messages (those that contain attachments) are part of the MIME standard, but described mainly -in RFC 2046 +in RFC 2046.
In the description below, good understanding of LTN012, Filters -sources and sinks and the MIME module is -assumed. In fact, the SMTP module was the main reason for their +sources and sinks and the MIME module is +assumed. In fact, the SMTP module was the main reason for their creation.
-+
To obtain the smtp namespace, run:
-+-- loads the SMTP module and everything it requires local smtp = require("socket.smtp")@@ -92,40 +92,40 @@ headers = {
Field names are case insensitive (as specified by the standard) and all functions work with lowercase field names (but see -socket.headers.canonic). +socket.headers.canonic). Field values are left unmodified.
-+
Note: MIME headers are independent of order. Therefore, there is no problem -in representing them in a Lua table. +in representing them in a Lua table.
The following constants can be set to control the default behavior of -the SMTP module: +the SMTP module:
-
-- DOMAIN: domain used to greet the server; -
- PORT: default port used for the connection; -
- SERVER: default server used for the connection; -
- TIMEOUT: default timeout for all I/O operations; -
- ZONE: default time zone. +
- DOMAIN: domain used to greet the server;
+- PORT: default port used for the connection;
+- SERVER: default server used for the connection;
+- TIMEOUT: default timeout for all I/O operations;
+- ZONE: default time zone.
+
smtp.message(mesgt)
-+
Returns a simple -LTN12 source that sends an SMTP message body, possibly multipart (arbitrarily deep). +LTN12 source that sends an SMTP message body, possibly multipart (arbitrarily deep).
-+
The only parameter of the function is a table describing the message. Mesgt has the following form (notice the recursive structure):
@@ -135,7 +135,7 @@ The only parameter of the function is a table describing the message.mesgt = {
headers = header-table,
- body = LTN12 source or string or + body = LTN12 source or string or multipart-mesgt
}
@@ -151,36 +151,36 @@ multipart-mesgt = {
-+
For a simple message, all that is needed is a set of headers and the body. The message body can be given as a string -or as a simple -LTN12 +or as a simple +LTN12 source. For multipart messages, the body is a table that recursively defines each part as an independent message, plus an optional preamble and epilogue.
--The function returns a simple -LTN12 +
+The function returns a simple +LTN12 source that produces the -message contents as defined by mesgt, chunk by chunk. +message contents as defined by mesgt, chunk by chunk. Hopefully, the following example will make things clear. When in doubt, refer to the appropriate RFC as listed in the introduction.
-+-- load the smtp support and its friends local smtp = require("socket.smtp") local mime = require("mime") local ltn12 = require("ltn12") --- creates a source to send a message with two parts. The first part is +-- creates a source to send a message with two parts. The first part is -- plain text, the second part is a PNG image, encoded as base64. source = smtp.message{ headers = { - -- Remember that headers are *ignored* by smtp.send. + -- Remember that headers are *ignored* by smtp.send. from = "Sicrano de Oliveira <sicrano@example.com>", to = "Fulano da Silva <fulano@example.com>", subject = "Here is a message with attachments" @@ -191,20 +191,20 @@ source = smtp.message{ "Preamble will probably appear even in a MIME enabled client.", -- first part: no headers means plain text, us-ascii. -- The mime.eol low-level filter normalizes end-of-line markers. - [1] = { + [1] = { body = mime.eol(0, [[ - Lines in a message body should always end with CRLF. - The smtp module will *NOT* perform translation. However, the + Lines in a message body should always end with CRLF. + The smtp module will *NOT* perform translation. However, the send function *DOES* perform SMTP stuffing, whereas the message function does *NOT*. ]]) }, - -- second part: headers describe content to be a png image, + -- second part: headers describe content to be a png image, -- sent under the base64 transfer content encoding. - -- notice that nothing happens until the message is actually sent. - -- small chunks are loaded into memory right before transmission and + -- notice that nothing happens until the message is actually sent. + -- small chunks are loaded into memory right before transmission and -- translation happens on the fly. - [2] = { + [2] = { headers = { ["content-type"] = 'image/png; name="image.png"', ["content-disposition"] = 'attachment; filename="image.png"', @@ -234,7 +234,7 @@ r, e = smtp.send{ -+
smtp.send{
-
from = string,
rcpt = string or string-table,
@@ -249,53 +249,53 @@ smtp.send{
}+
Sends a message to a recipient list. Since sending messages is not as -simple as downloading an URL from a FTP or HTTP server, this function -doesn't have a simple interface. However, see the -message source factory for +simple as downloading an URL from a FTP or HTTP server, this function +doesn't have a simple interface. However, see the +message source factory for a very powerful way to define the message contents.
--The sender is given by the e-mail address in the from field. +
+The sender is given by the e-mail address in the from field. Rcpt is a Lua table with one entry for each recipient e-mail address, or a string -in case there is just one recipient. -The contents of the message are given by a simple -LTN12 +in case there is just one recipient. +The contents of the message are given by a simple +LTN12 source. Several arguments are optional:
-
- user, password: User and password for authentication. The function will attempt LOGIN and PLAIN authentication -methods if supported by the server (both are unsafe); -
- server: Server to connect to. Defaults to "localhost"; -
- port: Port to connect to. Defaults to 25; +methods if supported by the server (both are unsafe);
+- server: Server to connect to. Defaults to "localhost";
+- port: Port to connect to. Defaults to 25;
- domain: Domain name used to greet the server; Defaults to the -local machine host name; -
- step: -LTN12 +local machine host name;
+- step: +LTN12 pump step function used to pass data from the -source to the server. Defaults to the LTN12 pump.step function; +source to the server. Defaults to the LTN12 pump.step function;
- create: An optional function to be used instead of -socket.tcp when the communications socket is created. +socket.tcp when the communications socket is created.
+
If successful, the function returns 1. Otherwise, the function returns nil followed by an error message.
-+
Note: SMTP servers can be very picky with the format of e-mail addresses. To be safe, use only addresses of the form "<fulano@example.com>" in the from and rcpt arguments to the send function. In headers, e-mail addresses can take whatever form you like.
-+
Big note: There is a good deal of misconception with the use of the destination address field headers, i.e., the 'To', 'Cc', and, more importantly, the 'Bcc' headers. Do not add a @@ -303,68 +303,69 @@ and, more importantly, the 'Bcc' headers. Do not add a exact opposite of what you expect.
-+
Only recipients specified in the rcpt list will receive a copy of the message. Each recipient of an SMTP mail message receives a copy of the message body along with the headers, and nothing more. The headers -are part of the message and should be produced by the -LTN12 +are part of the message and should be produced by the +LTN12 source function. The rcpt list is not part of the message and will not be sent to anyone.
-+
RFC 2822 has two important and short 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: +use of these headers. Here is a summary of what it says:
+Copy") contains addresses of recipients of the message whose addresses are not +to be revealed to other recipients of the message. + -
- To: contains the address(es) of the primary recipient(s) -of the message; +of the message;
- Cc: (where the "Cc" means "Carbon Copy" in the sense of making a copy on a typewriter using carbon paper) contains the addresses of others who are to receive the message, though the -content of the message may not be directed at them; +content of the message may not be directed at them;
- Bcc: (where the "Bcc" means "Blind Carbon -Copy") contains addresses of recipients of the message whose addresses are not to be revealed to other recipients of the message. -
-The LuaSocket send function does not care or interpret the -headers you send, but it gives you full control over what is sent and +
+The LuaSocket send function does not care or interpret the +headers you send, but it gives you full control over what is sent and to whom it is sent:
-
- If someone is to receive the message, the e-mail address has to be in the recipient list. This is the only parameter that controls who -gets a copy of the message; -
- If there are multiple recipients, none of them will automatically +gets a copy of the message;
+- If there are multiple recipients, none of them will automatically know that someone else got that message. That is, the default behavior is -similar to the Bcc field of popular e-mail clients; +similar to the Bcc field of popular e-mail clients;
- It is up to you to add the To header with the list of primary -recipients so that other recipients can see it; -
- It is also up to you to add the Cc header with the -list of additional recipients so that everyone else sees it; -
- Adding a header Bcc is nonsense, unless it is +recipients so that other recipients can see it;
+- It is also up to you to add the Cc header with the +list of additional recipients so that everyone else sees it;
+- Adding a header Bcc is nonsense, unless it is empty. Otherwise, everyone receiving the message will see it and that is -exactly what you don't want to happen! +exactly what you don't want to happen!
-I hope this clarifies the issue. Otherwise, please refer to +
+I hope this clarifies the issue. Otherwise, please refer to RFC 2821 and RFC 2822.
-+-- load the smtp support local smtp = require("socket.smtp") -- Connects to server "localhost" and sends a message to users --- "fulano@example.com", "beltrano@example.com", +-- "fulano@example.com", "beltrano@example.com", -- and "sicrano@example.com". -- Note that "fulano" is the primary recipient, "beltrano" receives a -- carbon copy and neither of them knows that "sicrano" received a blind @@ -388,17 +389,17 @@ mesgt = { r, e = smtp.send{ from = from, - rcpt = rcpt, + rcpt = rcpt, source = smtp.message(mesgt) }-+
- +
home · download · installation · diff --git a/doc/socket.html b/doc/socket.html index 35f8391..68db7cc 100644 --- a/doc/socket.html +++ b/doc/socket.html @@ -1,10 +1,10 @@ -
- +LuaSocket: The socket namespace @@ -13,22 +13,22 @@ -+
-
-- + - + Network support for the Lua language + Network support for the Lua language +
home · download · installation · introduction · -reference +reference
@@ -36,71 +36,71 @@ -The socket namespace
+The socket namespace
-The socket namespace contains the core functionality of LuaSocket. +The socket namespace contains the core functionality of LuaSocket.
-+
To obtain the socket namespace, run:
---- loads the socket module ++-- loads the socket module local socket = require("socket")-+
socket.headers.canonic
-The socket.headers.canonic table -is used by the HTTP and SMTP modules to translate from -lowercase field names back into their canonic +
The socket.headers.canonic 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.
-+
You can obtain the headers namespace if case run-time modifications are required by running:
---- loads the headers module ++-- loads the headers module local headers = require("headers")-+
socket.bind(address, port [, backlog])
-+
This function is a shortcut that creates and returns a TCP server object -bound to a local address and port, ready to +bound to a local address and port, ready to accept client connections. Optionally, -user can also specify the backlog argument to the -listen method (defaults to 32). +user can also specify the backlog argument to the +listen method (defaults to 32).
--Note: The server object returned will have the option "reuseaddr" +
+Note: The server object returned will have the option "reuseaddr" set to true.
-+
socket.connect[46](address, port [, locaddr] [, locport] [, family])
-+
This function is a shortcut that creates and returns a TCP client object connected to a remote address at a given port. Optionally, the user can also specify the local address and port to bind @@ -114,40 +114,40 @@ of connect are defined as simple helper functions that restrict the -
+
socket._DEBUG
-+
This constant is set to true if the library was compiled with debug support.
-+
socket._DATAGRAMSIZE
-+
Default datagram size used by calls to -receive and +receive and receivefrom. (Unless changed in compile time, the value is 8192.)
-+
socket.gettime()
-+
Returns the UNIX time in seconds. You should subtract the values returned by this function -to get meaningful values. +to get meaningful values.
-+t = socket.gettime() -- do stuff print(socket.gettime() - t .. " seconds elapsed") @@ -155,38 +155,38 @@ print(socket.gettime() - t .. " seconds elapsed") -+
socket.newtry(finalizer)
--Creates and returns a clean +
+Creates and returns a clean try -function that allows for cleanup before the exception -is raised. +function that allows for cleanup before the exception +is raised.
-+
Finalizer is a function that will be called before try throws the exception.
--The function returns your customized try function. +
+The function returns your customized try function.
--Note: This idea saved a lot of work with the -implementation of protocols in LuaSocket: +
+Note: This idea saved a lot of work with the +implementation of protocols in LuaSocket:
-+foo = socket.protect(function() -- connect somewhere local c = socket.try(socket.connect("somewhere", 42)) -- create a try function that closes 'c' on error local try = socket.newtry(function() c:close() end) - -- do everything reassured c will be closed + -- do everything reassured c will be closed try(c:send("hello there?\r\n")) local answer = try(c:receive()) ... @@ -198,40 +198,40 @@ end) -+
socket.protect(func)
-+
Converts a function that throws exceptions into a safe function. This -function only catches exceptions thrown by the try -and newtry functions. It does not catch normal +function only catches exceptions thrown by the try +and newtry functions. It does not catch normal Lua errors.
--Func is a function that calls -try (or assert, or error) -to throw exceptions. +
+Func is a function that calls +try (or assert, or error) +to throw exceptions.
-+
Returns an equivalent function that instead of throwing exceptions in case of -a failed try call, returns nil +a failed try call, returns nil followed by an error message.
-+
socket.select(recvt, sendt [, timeout])
--Waits for a number of sockets to change status. +
+Waits for a number of sockets to change status.
-+
Recvt is an array with the sockets to test for characters available for reading. Sockets in the sendt array are watched to see if it is OK to immediately write on them. Timeout is the @@ -242,7 +242,7 @@ be empty tables or nil. Non-socket values (or values with non-numeric indices) in the arrays will be silently ignored.
-The function returns a list with the sockets ready for +
The function returns a list with the sockets ready for reading, a list with the sockets ready for writing and an error message. The error message is "timeout" if a timeout condition was met, "select failed" if the call @@ -250,10 +250,10 @@ to select failed, and nil otherwise. The returned tables are doubly keyed both by integers and also by the sockets themselves, to simplify the test if a specific socket has -changed status. +changed status.
-+
Note: select can monitor a limited number of sockets, as defined by the constant socket._SETSIZE. This number may be as high as 1024 or as low as 64 by default, @@ -262,204 +262,204 @@ at compile time. Invoking select with a larger number of sockets will raise an error.
--Important note: a known bug in WinSock causes select to fail +
+Important note: a known bug in WinSock causes select to fail on non-blocking TCP sockets. The function may return a socket as writable even though the socket is not ready for sending.
-+
Another important note: calling select with a server socket in the receive parameter before a call to accept does not guarantee -accept will return immediately. -Use the settimeout -method or accept might block forever. +accept will return immediately. +Use the settimeout +method or accept might block forever.
-+
Yet another note: If you close a socket and pass it to select, it will be ignored.
-+
Using select with non-socket objects: Any object that implements getfd and dirty can be used with select, allowing objects from other libraries to be used within a socket.select driven loop.
-+
socket._SETSIZE
-+
The maximum number of sockets that the select function can handle. +href="#select">select function can handle.
-+
socket.sink(mode, socket)
--Creates an +
+Creates an LTN12 -sink from a stream socket object. +sink from a stream socket object.
-+
Mode defines the behavior of the sink. The following options are available:
- "http-chunked": sends data through socket after applying the -chunked transfer coding, closing the socket when done; +chunked transfer coding, closing the socket when done;
- "close-when-done": sends all received data through the -socket, closing the socket when done; +socket, closing the socket when done;
- "keep-open": sends all received data through the -socket, leaving it open when done. +socket, leaving it open when done.
-Socket is the stream socket object used to send the data. +Socket is the stream socket object used to send the data.
--The function returns a sink with the appropriate behavior. +
+The function returns a sink with the appropriate behavior.
-+
socket.skip(d [, ret1, ret2 ... retN])
-+
Drops a number of arguments and returns the remaining.
-+
D is the number of arguments to drop. Ret1 to retN are the arguments.
-+
The function returns retd+1 to retN.
-+
Note: This function is useful to avoid creation of dummy variables:
---- get the status code and separator from SMTP server reply ++-- get the status code and separator from SMTP server reply local code, sep = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"))-+
socket.sleep(time)
-+
Freezes the program execution during a given amount of time.
-+
Time is the number of seconds to sleep for. If time is negative, the function returns immediately.
-+
socket.source(mode, socket [, length])
--Creates an +
+Creates an LTN12 -source from a stream socket object. +source from a stream socket object.
-+
Mode defines the behavior of the source. The following options are available:
- "http-chunked": receives data from socket and removes the -chunked transfer coding before returning the data; +chunked transfer coding before returning the data;
- "by-length": receives a fixed number of bytes from the -socket. This mode requires the extra argument length; +socket. This mode requires the extra argument length;
- "until-closed": receives data from a socket until the other -side closes the connection. +side closes the connection.
-Socket is the stream socket object used to receive the data. +Socket is the stream socket object used to receive the data.
--The function returns a source with the appropriate behavior. +
+The function returns a source with the appropriate behavior.
-+
socket._SOCKETINVALID
-+
The OS value for an invalid socket.
-+
socket.try(ret1 [, ret2 ... retN])
-+
Throws an exception in case ret1 is falsy, using -ret2 as the error message. The exception is supposed to be caught -by a protected function only. +ret2 as the error message. The exception is supposed to be caught +by a protected function only.
-+
Ret1 to retN can be arbitrary -arguments, but are usually the return values of a function call -nested with try. +arguments, but are usually the return values of a function call +nested with try.
-+
The function returns ret1 to retN if ret1 is not nil or false. Otherwise, it calls error passing ret2 wrapped -in a table with metatable used by protect to +in a table with metatable used by protect to distinguish exceptions from runtime errors.
-+-- connects or throws an exception with the appropriate error message c = socket.try(socket.connect("localhost", 80))-+
socket._VERSION
--This constant has a string describing the current LuaSocket version. +
+This constant has a string describing the current LuaSocket version.
-+
- +
home · download · installation · diff --git a/doc/tcp.html b/doc/tcp.html index 6050a5f..2d6e327 100644 --- a/doc/tcp.html +++ b/doc/tcp.html @@ -13,17 +13,17 @@ -
+
-
-- + - + Network support for the Lua language + Network support for the Lua language +
home · download · installation · @@ -40,42 +40,43 @@ -
+
server:accept()
-+
Waits for a remote connection on the server object and returns a client object representing that connection.
-+
If a connection is successfully initiated, a client object is returned. If a timeout condition is met, the method returns nil followed by the error string 'timeout'. Other errors are reported by nil followed by a message describing the error.
--Note: calling socket.select +
+Note: calling socket.select with a server object in the recvt parameter before a call to accept does not guarantee accept will return immediately. Use the settimeout method or accept +href="#settimeout">settimeout method or accept might block until another client shows up.
-+
master:bind(address, port)
-+
Binds a master object to address and port on the local host. +
-+
Address can be an IP address or a host name. Port must be an integer number in the range [0..64K). If address @@ -86,25 +87,25 @@ If port is 0, the system automatically chooses an ephemeral port.
-+
In case of success, the method returns 1. In case of error, the method returns nil followed by an error message.
--Note: The function socket.bind +
+Note: The function socket.bind is available and is a shortcut for the creation of server sockets.
-+
master:close()
-
client:close()
server:close()+
Closes a TCP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations @@ -112,7 +113,7 @@ bound is made available to other applications. No further operations a closed socket.
-+
Note: It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are @@ -121,53 +122,53 @@ automatically closed before destruction, though. -
+
master:connect(address, port)
-+
Attempts to connect a master object to a remote host, transforming it into a client object. Client objects support methods -send, -receive, -getsockname, -getpeername, -settimeout, -and close. +send, +receive, +getsockname, +getpeername, +settimeout, +and close.
-+
Address can be an IP address or a host name. Port must be an integer number in the range [1..64K).
-+
In case of error, the method returns nil followed by a string describing the error. In case of success, the method returns 1.
--Note: The function socket.connect +
+Note: The function socket.connect is available and is a shortcut for the creation of client sockets.
-+
Note: Starting with LuaSocket 2.0, -the settimeout +the settimeout method affects the behavior of connect, causing it to return with an error in case of a timeout. If that happens, you can still call socket.select with the socket in the +href="socket.html#select">socket.select with the socket in the sendt table. The socket will be writable when the connection is established.
-+
Note: Starting with LuaSocket 3.0, the host name resolution depends on whether the socket was created by -socket.tcp, -socket.tcp4 or -socket.tcp6. Addresses from +socket.tcp, +socket.tcp4 or +socket.tcp6. Addresses from the appropriate family (or both) are tried in the order returned by the resolver until the first success or until the last failure. If the timeout was @@ -176,42 +177,42 @@ set to zero, only the first address is tried. -
+
master:dirty()
-
client:dirty()
server:dirty()+
Check the read buffer status.
-+
Returns true if there is any data in the read buffer, false otherwise.
-+
Note: This is an internal method, use at your own risk.
-+
master:getfd()
-
client:getfd()
server:getfd()+
Returns the underling socket descriptor or handle associated to the object.
-+
The descriptor or handle. In case the object has been closed, the return will be -1.
-+
Note: This is an internal method. Unlikely to be portable. Use at your own risk.
@@ -219,28 +220,27 @@ portable. Use at your own risk. --client:getoption(option)
-server:getoption(option) ++client:getoption(option)
-
+server:getoption(option)+
Gets options for the TCP object. -See setoption for description of the +See setoption for description of the option names and values.
--Option is a string with the option name. +
+Option is a string with the option name.
- -
-- 'keepalive' -
- 'linger' -
- 'reuseaddr' -
- 'tcp-nodelay' +
- 'keepalive'
+- 'linger'
+- 'reuseaddr'
+- 'tcp-nodelay'
+
The method returns the option value in case of success, or nil followed by an error message otherwise.
@@ -248,38 +248,38 @@ The method returns the option value in case of success, or -+
client:getpeername()
-+
Returns information about the remote side of a connected client object.
-+
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 ("inet" or "inet6"). In case of error, the method returns nil.
-+
Note: It makes no sense to call this method on server objects.
-+
master:getsockname()
-
client:getsockname()
server:getsockname()+
Returns the local address information associated to the object.
-+
The method returns a string with local IP address, a number with the local port, and a string with the family ("inet" or "inet6"). @@ -288,31 +288,31 @@ In case of error, the method returns nil. -
+
master:getstats()
-
client:getstats()
server:getstats()
+
Returns accounting information on the socket, useful for throttling of bandwidth.
-+
The method returns the number of bytes received, the number of bytes sent, and the age of the socket object in seconds.
-+
master:gettimeout()
-
client:gettimeout()
server:gettimeout()+
Returns the current block timeout followed by the curent total timeout.
@@ -320,65 +320,65 @@ total timeout. -+
master:listen(backlog)
-+
Specifies the socket is willing to receive connections, transforming the object into a server object. Server objects support the -accept, -getsockname, -setoption, -settimeout, -and close methods. +accept, +getsockname, +setoption, +settimeout, +and close methods.
-+
The parameter backlog specifies the number of client connections that can be queued waiting for service. If the queue is full and another client attempts connection, the connection is refused.
-+
In case of success, the method returns 1. In case of error, the method returns nil followed by an error message.
-+
client:receive([pattern [, prefix]])
-+
Reads data from a client object, according to the specified read pattern. Patterns follow the Lua file I/O format, and the difference in performance between all patterns is negligible.
-+
Pattern can be any of the following:
-
- '*a': reads from the socket until the connection is -closed. No end-of-line translation is performed; +closed. No end-of-line translation is performed;
- '*l': reads a line of text from the socket. The line is terminated by a LF character (ASCII 10), optionally preceded by a CR character (ASCII 13). The CR and LF characters are not included in the returned line. In fact, all CR characters are -ignored by the pattern. This is the default pattern; +ignored by the pattern. This is the default pattern;
- number: causes the method to read a specified number -of bytes from the socket. +of bytes from the socket.
+
Prefix is an optional string to be concatenated to the beginning of any received data before return.
-+
If successful, the method returns the received pattern. In case of error, the method returns nil followed by an error message, followed by a (possibly empty) string containing @@ -388,7 +388,7 @@ closed before the transmission was completed or the string 'timeout' in case there was a timeout during the operation.
-+
Important note: This function was changed severely. It used to support multiple patterns (but I have never seen this feature used) and now it doesn't anymore. Partial results used to be returned in the same @@ -399,22 +399,22 @@ too. -
+
client:send(data [, i [, j]])
-+
Sends data through client object.
-+
Data is the string to be sent. The optional arguments i and j work exactly like the standard string.sub Lua function to allow the selection of a substring to be sent.
-+
If successful, the method returns the index of the last byte within [i, j] that has been sent. Notice that, if i is 1 or absent, this is effectively the total @@ -428,7 +428,7 @@ was completed or the string 'timeout' in case there was a timeout during the operation.
-+
Note: Output is not buffered. For small strings, it is always better to concatenate them in Lua (with the '..' operator) and send the result in one call @@ -437,27 +437,27 @@ instead of calling the method several times. -
+
client:setoption(option [, value])
-
server:setoption(option [, value])+
Sets options for the TCP object. Options are only needed by low-level or time-critical applications. You should only modify an option if you are sure you need it.
-+
Option is a string with the option name, and value -depends on the option being set: +depends on the option being set:
-
- 'keepalive': Setting this option to true enables the periodic transmission of messages on a connected socket. Should the connected party fail to respond to these messages, the connection is -considered broken and processes using the socket are notified; +considered broken and processes using the socket are notified;
- 'linger': Controls the action taken when unsent data are queued on a socket and a close is performed. The value is a table with a @@ -468,79 +468,79 @@ it is able to transmit the data or until 'timeout' has passed. If 'on' is false and a close is issued, the system will process the close in a manner that allows the process to continue as quickly as possible. I do not advise you to set this to anything other than -zero; +zero;
- 'reuseaddr': Setting this option indicates that the rules used in validating addresses supplied in a call to -bind should allow reuse of local addresses; +bind should allow reuse of local addresses;
- 'tcp-nodelay': Setting this option to true -disables the Nagle's algorithm for the connection; +disables the Nagle's algorithm for the connection;
-- 'tcp-keepidle': value in seconds for TCP_KEEPIDLE Linux only!! +
- 'tcp-keepidle': value in seconds for TCP_KEEPIDLE Linux only!!
-- 'tcp-keepcnt': value for TCP_KEEPCNT Linux only!! +
- 'tcp-keepcnt': value for TCP_KEEPCNT Linux only!!
-- 'tcp-keepintvl': value for TCP_KEEPINTVL Linux only!! +
- 'tcp-keepintvl': value for TCP_KEEPINTVL Linux only!!
- 'ipv6-v6only': Setting this option to true restricts an inet6 socket to -sending and receiving only IPv6 packets. +sending and receiving only IPv6 packets.
+
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.
-+
master:setstats(received, sent, age)
-
client:setstats(received, sent, age)
server:setstats(received, sent, age)
+
Resets accounting information on the socket, useful for throttling of bandwidth.
-+
Received is a number with the new number of bytes received. Sent is a number with the new number of bytes sent. Age is the new age in seconds.
-+
The method returns 1 in case of success and nil otherwise.
-+
master:settimeout(value [, mode])
-
client:settimeout(value [, mode])
server:settimeout(value [, mode])+
Changes the timeout values for the object. By default, all I/O operations are blocking. That is, any call to the methods -send, -receive, and -accept +send, +receive, and +accept will block indefinitely, until the operation completes. The settimeout method defines a limit on the amount of time the I/O methods can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code.
-+
The amount of time to wait is specified as the value parameter, in seconds. There are two timeout modes and both can be used together for fine tuning: @@ -557,12 +557,12 @@ the amount of time LuaSocket can block a Lua script before returning from a call. -
+
The nil timeout value allows operations to block indefinitely. Negative timeout values have the same effect.
-+
Note: although timeout values have millisecond precision in LuaSocket, large blocks can cause I/O functions not to respect timeout values due to the time the library takes to transfer blocks to and from the OS @@ -571,7 +571,7 @@ and perform automatic name resolution might be blocked by the resolver for longer than the specified timeout value.
-+
Note: The old timeout method is deprecated. The name has been changed for sake of uniformity, since all other method names already contained verbs making their imperative nature obvious. @@ -579,123 +579,124 @@ contained verbs making their imperative nature obvious. -
+
client:shutdown(mode)
-
+
Shuts down part of a full-duplex connection.
-+
Mode tells which way of the connection should be shut down and can take the value:
+ -
- "both": disallow further sends and receives on the object. -This is the default mode; -
- "send": disallow further sends on the object; -
- "receive": disallow further receives on the object. +This is the default mode;
+- "send": disallow further sends on the object;
+- "receive": disallow further receives on the object.
+
This function returns 1.
-+
master:setfd(fd)
-
client:setfd(fd)
server:setfd(fd)+
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.
-+
No return value.
-+
Note: This is an internal method. Unlikely to be portable. Use at your own risk.
-+
socket.tcp()
-+
Creates and returns an 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 +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.
+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 choice between IPv4 and IPv6 happens during a call to -bind or connect, depending on the address +bind or connect, depending on the address family obtained from the resolver.
-+
Note: Before the choice between IPv4 and IPv6 happens, the internal socket object is invalid and therefore setoption will fail. +href="#setoption">setoption will fail.
-+
socket.tcp4()
-+
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 -the method connect. The only other +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.
+close method. -+
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 +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.
+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.
@@ -704,10 +705,10 @@ Note: The TCP object returned will have the option -+
- +
home · download · installation · diff --git a/doc/udp.html b/doc/udp.html index 4618aad..db711cb 100644 --- a/doc/udp.html +++ b/doc/udp.html @@ -13,17 +13,17 @@ -
+
-
-- + - + Network support for the Lua language + Network support for the Lua language +
home · download · installation · @@ -71,26 +71,26 @@ unconnected:getoption()
Gets an option value from the UDP object. -See setoption for +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' +
- '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. @@ -108,7 +108,7 @@ associated with a connected UDP object.
-+
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 ("inet" or "inet6"). @@ -131,7 +131,7 @@ Returns the local address information associated to the object.
-+
The method returns a string with local IP address, a number with the local port, and a string with the family ("inet" or "inet6"). @@ -148,12 +148,12 @@ wild-card address). -
+
connected:settimeout(value)
-
unconnected:settimeout(value)+
Returns the current timeout value.
@@ -180,8 +180,8 @@ the excess bytes are discarded. If there are less then size bytes available in the current datagram, the available bytes are returned. If size is omitted, the -compile-time constant socket._DATAGRAMSIZE is used +compile-time constant +socket._DATAGRAMSIZE is used (it defaults to 8192 bytes). Larger sizes will cause a temporary buffer to be allocated for the operation. @@ -286,45 +286,45 @@ name, and value depends on the option being set:
- 'dontroute': Indicates that outgoing messages should bypass the standard routing facilities. -Receives a boolean value; +Receives a boolean value;
- 'broadcast': Requests permission to send broadcast datagrams on the socket. -Receives a boolean value; +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; +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; +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; +Receives a boolean value;
- 'ipv6-v6only': Specifies whether to restrict inet6 sockets to sending and receiving only IPv6 packets. -Receive a boolean value; +Receive a boolean value;
- 'ip-multicast-if': Sets the interface over which outgoing multicast datagrams are sent. -Receives an IP address; +Receives an IP address;
- 'ip-multicast-ttl': Sets the Time To Live in the IP header for outgoing multicast datagrams. -Receives a number; +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 address;
- 'ip-drop-membership': Leaves the multicast group specified. Receives a table with fields multiaddr and interface, each containing an -IP address. +IP address.
@@ -332,7 +332,7 @@ 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.
@@ -381,11 +381,11 @@ is recommended when the same peer is used for several transmissions and can result in up to 30% performance gains. -+
Note: Starting with LuaSocket 3.0, the host name resolution depends on whether the socket was created by socket.udp or socket.udp6. Addresses from +href="#socket.udp">socket.udp or socket.udp6. Addresses from the appropriate family are tried in succession until the first success or until the last failure.
@@ -492,23 +492,23 @@ returned. In case of error, nil is returned, followed by an error message. -+
Note: The choice between IPv4 and IPv6 happens during a call to -sendto, setpeername, or sockname, depending on the address +sendto, setpeername, or sockname, depending on the address family obtained from the resolver.
-+
Note: Before the choice between IPv4 and IPv6 happens, the internal socket object is invalid and therefore setoption will fail. +href="#setoption">setoption will fail.
-+
socket.udp4()
@@ -564,7 +564,7 @@ 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.
@@ -573,10 +573,10 @@ Note: The TCP object returned will have the option -+
- +
home · download · installation ·