Your IP : 216.73.216.86


Current Path : /home/emeraadmin/public_html/4d695/
Upload File :
Current File : /home/emeraadmin/public_html/4d695/lua-socket.zip

PKN��\�)����READMEnu�[���This is the LuaSocket 3.0-rc1. It has been tested on Windows 7, Mac OS X,
and Linux. 

Please use the project page at GitHub 

    https://github.com/diegonehab/luasocket

to file bug reports or propose changes. 

Have fun,
Diego Nehab.
PKN��\��ξffdns.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: DNS support">
<meta name="keywords" content="Lua, LuaSocket, DNS, Network, Library, Support">
<title>LuaSocket: DNS support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- dns ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=dns>DNS</h2> 

<p>
IPv4 name resolution functions 
<a href=#toip><tt>dns.toip</tt></a>
and
<a href=#tohostname><tt>dns.tohostname</tt></a>
return <em>all</em> information obtained from 
the resolver in a table of the form:
</p>

<blockquote><tt>
resolved4 = {<br>
&nbsp;&nbsp;name = <i>canonic-name</i>,<br>
&nbsp;&nbsp;alias = <i>alias-list</i>,<br>
&nbsp;&nbsp;ip = <i>ip-address-list</i><br>
}
</tt> </blockquote>

<p>
Note that the <tt>alias</tt> list can be empty.
</p>

<p>
The more general name resolution function 
<a href=#getaddrinfo><tt>dns.getaddrinfo</tt></a>, which
supports both IPv6 and IPv4,
returns <em>all</em> information obtained from 
the resolver in a table of the form:
</p>

<blockquote><tt>
resolved6 = {<br>
&nbsp;&nbsp;[1] = {<br>
&nbsp;&nbsp;&nbsp;&nbsp;family = <i>family-name-1</i>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;addr = <i>address-1</i><br>
&nbsp;&nbsp;},<br>
&nbsp;&nbsp;...<br>
&nbsp;&nbsp;[n] = {<br>
&nbsp;&nbsp;&nbsp;&nbsp;family = <i>family-name-n</i>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;addr = <i>address-n</i><br>
&nbsp;&nbsp;}<br>
}
</tt> </blockquote>

<p>
Here, <tt>family</tt> contains the string <tt>"inet"</tt> for IPv4
addresses, and <tt>"inet6"</tt> for IPv6 addresses.
</p>

<!-- getaddrinfo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=getaddrinfo> 
socket.dns.<b>getaddrinfo(</b>address<b>)</b>
</p>

<p class=description>
Converts from host name to address. 
</p>

<p class=parameters>
<tt>Address</tt> can  be an IPv4 or IPv6 address or host name. 
</p>

<p class=return>
The function returns a table with  all  information returned  by
the  resolver.  In  case of error, the function returns <b><tt>nil</tt></b>
followed by an error message.  
</p>

<!-- gethostname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=gethostname> 
socket.dns.<b>gethostname()</b>
</p>

<p class=description>
Returns the standard host name for the machine as a string. 
</p>

<!-- tohostname +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=tohostname> 
socket.dns.<b>tohostname(</b>address<b>)</b>
</p>

<p class=description>
Converts from IPv4 address to host name.
</p>

<p class=parameters>
<tt>Address</tt> can  be an IP address  or host name. 
</p>

<p class=return>
The function returns a string  with the canonic host name of the given
<tt>address</tt>, followed  by a  table with  all  information returned  by
the  resolver.  In  case of error, the function returns <b><tt>nil</tt></b>
followed by an error message.  
</p>

<!-- toip +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=toip> 
socket.dns.<b>toip(</b>address<b>)</b>
</p>

<p class=description>
Converts from host name to IPv4 address.
</p>

<p class=parameters>
<tt>Address</tt> can  be an IP address  or host name. 
</p>

<p class=return> 
Returns a string  with the first IP address  found for <tt>address</tt>,
followed  by a  table with  all  information returned  by the  resolver.
In  case of error, the function returns <b><tt>nil</tt></b> followed by an error
message. 
</p>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:07 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\�b�]%]%ftp.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd"> 
<html>

<head>
<meta name="description" content="LuaSocket: FTP support">
<meta name="keywords" content="Lua, LuaSocket, FTP, Network, Library, Support">
<title>LuaSocket: FTP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- ftp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=ftp>FTP</h2> 

<p>
FTP  (File Transfer  Protocol)  is a  protocol  used  to transfer  files
between hosts.  The <tt>ftp</tt> namespace offers thorough support
to FTP, under a simple interface. The implementation conforms to
<a href="http://www.ietf.org/rfc/rfc959.txt">RFC 959</a>.
</p>

<p>
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 <em>any</em> operation supported by the FTP
protocol.  For that, check the implementation.  
</p>

<p>
To really benefit from this module, a good understanding of 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">
LTN012, Filters sources and sinks</a> is necessary. 
</p>

<p> 
To obtain the <tt>ftp</tt> namespace, run:
</p>

<pre class=example>
-- loads the FTP module and any libraries it requires
local ftp = require("socket.ftp")
</pre>

<p>
URLs MUST conform to
<a href="http://www.ietf.org/rfc/rfc1738.txt">RFC 1738</a>, 
that is, an URL is a string in the form: 
</p>

<blockquote>
<tt>
[ftp://][&lt;user&gt;[:&lt;password&gt;]@]&lt;host&gt;[:&lt;port&gt;][/&lt;path&gt;][<i>type</i>=a|i]</tt>
</blockquote>

<p>
The following constants in the namespace can be set to control the default behavior of
the FTP module: 
</p>

<ul>
<li> <tt>PASSWORD</tt>: default anonymous password.
<li> <tt>PORT</tt>: default port used for the control connection;
<li> <tt>TIMEOUT</tt>: sets the timeout for all I/O operations;
<li> <tt>USER</tt>: default anonymous user;
</ul>


<!-- ftp.get ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=get>
ftp.<b>get(</b>url<b>)</b><br>
ftp.<b>get{</b><br>
&nbsp;&nbsp;host = <i>string</i>,<br>
&nbsp;&nbsp;sink = <i>LTN12 sink</i>,<br>
&nbsp;&nbsp;argument <i>or</i> path = <i>string</i>,<br>
&nbsp;&nbsp;[user = <i>string</i>,]<br>
&nbsp;&nbsp;[password = <i>string</i>]<br>
&nbsp;&nbsp;[command = <i>string</i>,]<br>
&nbsp;&nbsp;[port = <i>number</i>,]<br>
&nbsp;&nbsp;[type = <i>string</i>,]<br>
&nbsp;&nbsp;[step = <i>LTN12 pump step</i>,]<br>
&nbsp;&nbsp;[create = <i>function</i>]<br>
<b>}</b>
</p>

<p class=description>
The <tt>get</tt> 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 <em>lot</em> more control, as explained
below.
</p>

<p class=parameters>
If the argument of the <tt>get</tt> function is a table, the function
expects at least the fields <tt>host</tt>, <tt>sink</tt>, and one of 
<tt>argument</tt> or <tt>path</tt> (<tt>argument</tt> takes
precedence). <tt>Host</tt> is the server to connect to. <tt>Sink</tt> is
the <em>simple</em> 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
sink that will receive the downloaded data. <tt>Argument</tt> or
<tt>path</tt> give the target path to the resource in the server. The
optional arguments are the following:
</p>
<ul>
<li><tt>user</tt>, <tt>password</tt>: User name and password used for
authentication. Defaults to "<tt>ftp:anonymous@anonymous.org</tt>";
<li><tt>command</tt>: The FTP command used to obtain data. Defaults to
"<tt>retr</tt>", but see example below;
<li><tt>port</tt>: The port to used for the control connection. Defaults to 21;
<li><tt>type</tt>: The transfer mode. Can take values "<tt>i</tt>" or
"<tt>a</tt>". Defaults to whatever is the server default;
<li><tt>step</tt>: 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
pump step function used to pass data from the
server to the sink. Defaults to the LTN12 <tt>pump.step</tt> function;
<li><tt>create</tt>: An optional function to be used instead of
<a href=tcp.html#socket.tcp><tt>socket.tcp</tt></a> when the communications socket is created. 
</ul>

<p class=return>
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 <b><tt>nil</tt></b> and an error message describing the
error.  
</p>

<pre class=example>
-- load the ftp support
local ftp = require("socket.ftp")

-- Log as user "anonymous" on server "ftp.tecgraf.puc-rio.br",
-- and get file "lua.tar.gz" from directory "pub/lua" as binary.
f, e = ftp.get("ftp://ftp.tecgraf.puc-rio.br/pub/lua/lua.tar.gz;type=i")
</pre>

<pre class=example>
-- load needed modules
local ftp = require("socket.ftp")
local ltn12 = require("ltn12")
local url = require("socket.url")

-- a function that returns a directory listing
function nlst(u)
    local t = {}
    local p = url.parse(u)
    p.command = "nlst"
    p.sink = ltn12.sink.table(t)
    local r, e = ftp.get(p)
    return r and table.concat(t), e
end
</pre>

<!-- put ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=put>
ftp.<b>put(</b>url, content<b>)</b><br>
ftp.<b>put{</b><br>
&nbsp;&nbsp;host = <i>string</i>,<br>
&nbsp;&nbsp;source = <i>LTN12 sink</i>,<br>
&nbsp;&nbsp;argument <i>or</i> path = <i>string</i>,<br>
&nbsp;&nbsp;[user = <i>string</i>,]<br>
&nbsp;&nbsp;[password = <i>string</i>]<br>
&nbsp;&nbsp;[command = <i>string</i>,]<br>
&nbsp;&nbsp;[port = <i>number</i>,]<br>
&nbsp;&nbsp;[type = <i>string</i>,]<br>
&nbsp;&nbsp;[step = <i>LTN12 pump step</i>,]<br>
&nbsp;&nbsp;[create = <i>function</i>]<br>
<b>}</b>
</p>

<p class=description>
The <tt>put</tt> function has two forms. The simple form has fixed
functionality: it uploads a string of content into a URL. The generic form
allows a <em>lot</em> more control, as explained below.  
</p>

<p class=parameters>
If the argument of the <tt>put</tt> function is a table, the function
expects at least the fields <tt>host</tt>, <tt>source</tt>, and one of 
<tt>argument</tt> or <tt>path</tt> (<tt>argument</tt> takes
precedence). <tt>Host</tt> is the server to connect to. <tt>Source</tt> is
the <em>simple</em> 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
source that will provide the contents to be uploaded. 
<tt>Argument</tt> or
<tt>path</tt> give the target path to the resource in the server. The
optional arguments are the following:
</p>
<ul>
<li><tt>user</tt>, <tt>password</tt>: User name and password used for
authentication. Defaults to "<tt>ftp:anonymous@anonymous.org</tt>";
<li><tt>command</tt>: The FTP command used to send data. Defaults to
"<tt>stor</tt>", but see example below;
<li><tt>port</tt>: The port to used for the control connection. Defaults to 21;
<li><tt>type</tt>: The transfer mode. Can take values "<tt>i</tt>" or
"<tt>a</tt>". Defaults to whatever is the server default;
<li><tt>step</tt>: 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
pump step function used to pass data from the
server to the sink. Defaults to the LTN12 <tt>pump.step</tt> function;
<li><tt>create</tt>: An optional function to be used instead of
<a href=tcp.html#socket.tcp><tt>socket.tcp</tt></a> when the communications socket is created. 
</ul>

<p class=return>
Both functions return 1 if successful, or <b><tt>nil</tt></b> and an error
message describing the reason for failure.
</p>

<pre class=example>
-- 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 
-- "wrong password, of course"
f, e = ftp.put("ftp://fulano:silva@ftp.example.com/README", 
    "wrong password, of course")
</pre>

<pre class=example>
-- load the ftp support
local ftp = require("socket.ftp")
local ltn12 = require("ltn12")

-- Log as user "fulano" on server "ftp.example.com",
-- 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", 
  user = "fulano",
  password = "silva",
  command = "appe",
  argument = "LOG",
  source = ltn12.source.file(io.open("LOCAL-LOG", "r"))
}
</pre>


<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:18 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\s�if�,�,	http.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: HTTP support">
<meta name="keywords" content="Lua, HTTP, Library, WWW, Browser, Network, Support"> 
<title>LuaSocket: HTTP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- http +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id="http">HTTP</h2> 

<p>
HTTP (Hyper Text  Transfer Protocol) is the protocol  used to exchange
information  between  web-browsers and  servers.  The  <tt>http</tt>
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,
<a href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a>.
</p>

<p>
The module exports functions that provide HTTP functionality in different
levels of abstraction. From the simple 
string oriented requests, through generic
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> based, down to even lower-level if you bother to look through the source code.
</p>

<p> 
To obtain the <tt>http</tt> namespace, run:
</p>

<pre class=example>
-- loads the HTTP module and any libraries it requires
local http = require("socket.http")
</pre>

<p>
URLs must conform to
<a href="http://www.ietf.org/rfc/rfc1738.txt">RFC 1738</a>,
that is, an URL is a string in the form: 
</p>

<blockquote>
<pre>
[http://][&lt;user&gt;[:&lt;password&gt;]@]&lt;host&gt;[:&lt;port&gt;][/&lt;path&gt;] 
</pre>
</blockquote>

<p>
MIME headers are represented as a Lua table in the form:
</p>

<blockquote>
<table summary="MIME headers in Lua table">
<tr><td><tt>
headers = {<br>
&nbsp;&nbsp;field-1-name = <i>field-1-value</i>,<br>
&nbsp;&nbsp;field-2-name = <i>field-2-value</i>,<br>
&nbsp;&nbsp;field-3-name = <i>field-3-value</i>,<br>
&nbsp;&nbsp;...<br>
&nbsp;&nbsp;field-n-name = <i>field-n-value</i><br>
}
</tt></td></tr>
</table>
</blockquote>

<p>
Field names are case insensitive (as specified by the standard) and all
functions work with lowercase field names (but see
<a href=socket.html#headers.canonic><tt>socket.headers.canonic</tt></a>).
Field values are left unmodified.
</p>

<p class=note>
Note: MIME headers are independent of order. Therefore, there is no problem
in representing them in a Lua table. 
</p>

<p>
The following constants can be set to control the default behavior of
the HTTP module: 
</p>

<ul>
<li> <tt>PORT</tt>: default port used for connections; 
<li> <tt>PROXY</tt>: default proxy used for connections; 
<li> <tt>TIMEOUT</tt>: sets the timeout for all I/O operations;
<li> <tt>USERAGENT</tt>: default user agent reported to server.
</ul>


<!-- http.request ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="request">
http.<b>request(</b>url [, body]<b>)</b><br>
http.<b>request{</b><br>
&nbsp;&nbsp;url = <i>string</i>,<br>
&nbsp;&nbsp;[sink = <i>LTN12 sink</i>,]<br>
&nbsp;&nbsp;[method = <i>string</i>,]<br>
&nbsp;&nbsp;[headers = <i>header-table</i>,]<br>
&nbsp;&nbsp;[source = <i>LTN12 source</i>],<br>
&nbsp;&nbsp;[step = <i>LTN12 pump step</i>,]<br>
&nbsp;&nbsp;[proxy = <i>string</i>,]<br>
&nbsp;&nbsp;[redirect = <i>boolean</i>,]<br>
&nbsp;&nbsp;[create = <i>function</i>]<br>
<b>}</b>
</p>

<p class=description>
The request function has two forms. The simple form downloads 
a URL using the <tt>GET</tt> or <tt>POST</tt> method and is based 
on strings. The generic form performs any HTTP method and is 
<a href=http://lua-users.org/wiki/FiltersSourcesAndSinks>LTN12</a> based.
</p>

<p class=parameters>
If the first argument of the <tt>request</tt> function is a string, it
should be an <tt>url</tt>. In that case, if a <tt>body</tt>
is provided as a string, the function will perform a <tt>POST</tt> method
in the <tt>url</tt>. Otherwise, it performs a <tt>GET</tt> in the
<tt>url</tt> 
</p>

<p class=parameters>
If the first argument is instead a table, the most important fields are 
the <tt>url</tt> and the <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
<tt>sink</tt> that will receive the downloaded content.  
Any part of the <tt>url</tt> can be overridden by including
the appropriate field in the request table.
If authentication information is provided, the function
uses the  Basic Authentication Scheme (see  <a href="#authentication">note</a>)
to retrieve  the document. If <tt>sink</tt> is <tt><b>nil</b></tt>, the
function discards the downloaded data. The optional parameters are the
following:
</p>
<ul>
<li><tt>method</tt>: The HTTP request method. Defaults to "GET"; 
<li><tt>headers</tt>: Any additional HTTP headers to send with the request; 
<li><tt>source</tt>: <em>simple</em> 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
source to provide the request body. If there
is a body, you need to provide an appropriate "<tt>content-length</tt>"
request header field, or the function will attempt to send the body as
"<tt>chunked</tt>" (something few servers support). Defaults to the empty source; 
<li><tt>step</tt>: 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
pump step function used to move data.  
Defaults to the LTN12 <tt>pump.step</tt> function.
<li><tt>proxy</tt>: The URL of a proxy server to use. Defaults to no proxy; 
<li><tt>redirect</tt>: Set to <tt><b>false</b></tt> to prevent the 
function from  automatically following 301 or 302 server redirect messages; 
<li><tt>create</tt>: An optional function to be used instead of
<a href=tcp.html#socket.tcp><tt>socket.tcp</tt></a> when the communications socket is created. 
</ul>

<p class=return>
In case of failure, the function returns <tt><b>nil</b></tt> followed by an
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 <tt>sink</tt>).
</p>

<p class=return>
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 <tt>code</tt>. For
a  list  of  the  possible  values  and  their  meanings,  refer  to  <a
href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a>. 
</p>

<p class=description>
Here are a few examples with the simple interface:
</p>

<pre class=example>
-- load the http module
local io = require("io")
local http = require("socket.http")
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", 
    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, 
-- h returns authentication information
-- and c returns with value 401 (Authentication Required)

-- tries to connect to server "wrong.host" to retrieve "/"
-- and fails because the host does not exist.
r, e = http.request("http://wrong.host/")
-- r is nil, and e returns with value "host not found"
</pre>

<p class=description>
And here is an example using the generic interface:
</p>

<pre class=example>
-- load the http module
http = require("socket.http")

-- Requests information about a document, without downloading it.
-- Useful, for example, if you want to display a download gauge and need
-- to know the size of the document in advance
r, c, h = http.request {
  method = "HEAD",
  url = "http://www.tecgraf.puc-rio.br/~diego"
}
-- r is 1, c is 200, and h would return the following headers:
-- h = {
--   date = "Tue, 18 Sep 2001 20:42:21 GMT",
--   server = "Apache/1.3.12 (Unix)  (Red Hat/Linux)",
--   ["last-modified"] = "Wed, 05 Sep 2001 06:11:20 GMT",
--   ["content-length"] = 15652,
--   ["connection"] = "close",
--   ["content-Type"] = "text/html"
-- }
</pre>

<p class=note id="post"> 
Note: When sending a POST request, simple interface adds a
"<tt>Content-type: application/x-www-form-urlencoded</tt>"
header to the request. This is the type used by
HTML forms. If you need another type, use the generic
interface.
</p>

<p class=note id="authentication"> 
Note: Some URLs are protected by their
servers from anonymous download. For those URLs, the server must receive
some  sort of  authentication along  with the  request or  it will  deny
download and return status "401&nbsp;Authentication Required". 
</p>

<p class=note>
The  HTTP/1.1 standard  defines  two authentication  methods: the  Basic
Authentication  Scheme  and  the   Digest  Authentication  Scheme,  both
explained in detail in
<a href="http://www.ietf.org/rfc/rfc2068.txt">RFC 2068</a>.
</p>

<p class=note>The Basic  Authentication   Scheme  sends   
<tt>&lt;user&gt;</tt>  and
<tt>&lt;password&gt;</tt>  unencrypted to  the server  and is  therefore
considered unsafe.  Unfortunately, by  the time of  this implementation,
the wide majority of servers and browsers support the Basic Scheme only.
Therefore,   this  is   the  method   used  by   the  toolkit   whenever
authentication is required.
</p>

<pre class=example>
-- load required modules
http = require("socket.http")
mime = require("mime")

-- Connect to server "www.example.com" and tries to retrieve
-- "/private/index.html", using the provided name and password to
-- authenticate the request
b, c, h = http.request("http://fulano:silva@www.example.com/private/index.html")

-- Alternatively, one could fill the appropriate header and authenticate
-- the request directly.
r, c = http.request {
  url = "http://www.example.com/private/index.html",
  headers = { authorization = "Basic " .. (mime.b64("fulano:silva")) }
}
</pre>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:26 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\>�-��
index.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="The LuaSocket Homepage">
<meta name="keywords" content="Lua, LuaSocket, Network, Library, Support, Internet">
<title>LuaSocket: Network support for the Lua language </title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- whatis +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=whatis>What is LuaSocket?</h2>

<p>
LuaSocket  is a  <a href="http://www.lua.org">Lua</a>  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. 
</p>

<p>
The core support has been  implemented so that it  is both efficient and
simple to use.  It is available to any Lua application once it has been
properly initialized by the interpreter in use. The code has been tested
and runs well on several Windows and UNIX platforms. </p>

<p>
Among the support modules, the most commonly used implement the 
<a href=smtp.html>SMTP</a>
(sending  e-mails),  
<a href=http.html>HTTP</a>
(WWW access)  and  
<a href=ftp.html>FTP</a>  
(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 
<a href=mime.html>MIME</a> (common encodings), 
<a href=url.html>URL</a> 
(anything you could possible want to do with one) and 
<a href=ltn12.html>LTN12</a> 
(filters, sinks, sources and pumps) modules can be very handy. 
</p>

<p>
The library is available under the same  
<a href="http://www.lua.org/copyright.html">
terms and conditions</a> 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 
LuaSocket.
</p>

<p>
Copyright &copy; 1999-2013 Diego Nehab. All rights reserved. <br>
Author: <A href="http://www.impa.br/~diego">Diego Nehab</a>
</p>

<!-- download +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=download>Download</h2>

<p>
LuaSocket version 3.0-rc1 is now available for download! 
It is compatible with  Lua&nbsp;5.1 and 5.2, and has    
been tested on Windows&nbsp;XP, Linux, and Mac OS X. Chances
are it works well on most UNIX distributions and Windows flavors.
</p>

<p>
The current version of the library can be found at
the <a href="https://github.com/diegonehab/luasocket">LuaSocket
project page</a> 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.
</p>

<p> Take a look at the <a
href=installation.html>installation</a> section of the
manual to find out how to properly install the library.
</p>

<!-- thanks +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=thanks>Special thanks</h2>

<p>
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. 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. 
</p>

<!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=new>What's New</h2>

<p>
Main changes for LuaSocket&nbsp;3.0-rc1 are IPv6 support
and Lua&nbsp;5.2 compatibility. 
</p>

<ul>
<li> Added: Compatible with Lua&nbsp;5.2 
<ul>
<li> Note that unless you define <tt>LUA_COMPAT_MODULE</tt>,
package tables will <em>not</em> be exported as globals!
</ul>
<li> Added: IPv6 support;
<ul>
<li> <tt>Socket.connect</tt> and <tt>socket.bind</tt> support IPv6 addresses;
<li> <tt>Getpeername</tt> and <tt>getsockname</tt> support
IPv6 addresses, and return the socket family as a third value;
<li> URL module updated to support IPv6 host names;
<li> New <tt>socket.tcp6</tt> and <tt>socket.udp6</tt> functions;
<li> New <tt>socket.dns.getaddrinfo</tt> and 
    <tt>socket.dns.getnameinfo</tt> functions;
</ul>
<li> Added: <tt>getoption</tt> method;
<li> Fixed: <tt>url.unescape</tt> was returning additional values;
<li> Fixed: <tt>mime.qp</tt>, <tt>mime.unqp</tt>, 
    <tt>mime.b64</tt>, and <tt>mime.unb64</tt> could
    mistaking their own stack slots for functions arguments;
<li> Fixed: Receiving zero-length datagram is now possible;
<li> Improved: Hidden all internal library symbols;
<li> Improved: Better error messages;
<li> Improved: Better documentation of socket options.
<li> Fixed: manual sample of HTTP authentication now uses correct
     "authorization" header (Alexandre Ittner);
<li> Fixed: failure on bind() was destroying the socket (Sam Roberts);
<li> Fixed: receive() returns immediatelly if prefix can satisfy
     bytes requested (M Joonas Pihlaja);
<li> Fixed: multicast didn't work on Windows, or anywhere
     else for that matter (Herbert Leuwer, Adrian Sietsma);
<li> Fixed: select() now reports an error when called with more
     sockets than FD_SETSIZE (Lorenzo Leonini);
<li> Fixed: manual links to home.html changed to index.html
(Robert Hahn);
<li> Fixed: mime.unb64() would return an empty string on results that started
     with a null character (Robert Raschke);
<li> Fixed: HTTP now automatically redirects on 303 and 307 (Jonathan Gray);
<li> Fixed: calling sleep() with negative numbers could
     block forever, wasting CPU. Now it returns immediately (MPB);
<li> Improved: FTP commands are now sent in upper case to
     help buggy servers (Anders Eurenius);
<li> Improved: known headers now sent in canonic
     capitalization to help buggy servers (Joseph Stewart);
<li> Improved: Clarified tcp:receive() in the manual (MPB);
<li> Improved: Decent makefiles (LHF).
<li> Fixed: RFC links in documentation now point to IETF (Cosmin Apreutesei).
</ul>

<!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=old>Old Versions</h2>

<p>
All  previous versions  of the  LuaSocket library  can be  downloaded <a
href="http://www.impa.br/~diego/software/luasocket/old">
here</a>. Although these  versions are  no longer  supported, they  are
still available for those that have compatibility issues. 
</p>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Tue Jun 11 18:50:23 HKT 2013
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\-)
D++installation.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: Introduction to the core">
<meta name="keywords" content="Lua, LuaSocket, TCP, UDP, Network, Support,
Installation"> 
<title>LuaSocket: Installation</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- installation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2>Installation</h2>

<p> Here we describe the standard distribution.  If the
standard doesn't meet your needs, we refer you to the Lua
discussion list, where any question about the package scheme
will likely already have been answered.  </p>

<h3>Directory structure</h3>

<p> On Unix systems, the standard distribution uses two base
directories, one for system dependent files, and another for system
independent files. Let's call these directories <tt>&lt;CDIR&gt;</tt> 
and <tt>&lt;LDIR&gt;</tt>, respectively. 
For example, in my laptp, Lua&nbsp;5.1 is configured to
use '<tt>/usr/local/lib/lua/5.1</tt>' for
<tt>&lt;CDIR&gt;</tt> and '<tt>/usr/local/share/lua/5.1</tt>' for
<tt>&lt;LDIR&gt;</tt>. On Windows, <tt>&lt;CDIR&gt;</tt>
usually points to the directory where the Lua executable is
found, and <tt>&lt;LDIR&gt;</tt> points to a
<tt>lua/</tt> directory inside <tt>&lt;CDIR&gt;</tt>. (These
settings can be overridden by environment variables 
<tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt>. See the Lua
documentation for details.) Here is the standard LuaSocket 
distribution directory structure:</p>

<pre class=example>
&lt;LDIR&gt;/ltn12.lua
&lt;LDIR&gt;/socket.lua
&lt;CDIR&gt;/socket/core.dll
&lt;LDIR&gt;/socket/http.lua
&lt;LDIR&gt;/socket/tp.lua
&lt;LDIR&gt;/socket/ftp.lua
&lt;LDIR&gt;/socket/smtp.lua
&lt;LDIR&gt;/socket/url.lua
&lt;LDIR&gt;/mime.lua
&lt;CDIR&gt;/mime/core.dll
</pre>

<p> Naturally, on Unix systems, <tt>core.dll</tt>
would be replaced by <tt>core.so</tt>.  
</p>

<h3>Using LuaSocket</h3>

<p> With the above setup, and an interpreter with shared library support,
it should be easy to use LuaSocket. Just fire the interpreter and use the
<tt>require</tt> function to gain access to whatever module you need:</p>

<pre class=example>
Lua 5.2.2  Copyright (C) 1994-2013 Lua.org, PUC-Rio
&gt; socket = require("socket")
&gt; print(socket._VERSION)
--&gt; LuaSocket 3.0-rc1
</pre>

<p> Each module loads their dependencies automatically, so you only need to
load the modules you directly depend upon: </p>

<pre class=example>
Lua 5.2.2  Copyright (C) 1994-2013 Lua.org, PUC-Rio
&gt; http = require("socket.http")
&gt; print(http.request("http://www.impa.br/~diego/software/luasocket"))
--&gt; homepage gets dumped to terminal
</pre>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Tue Jun 11 19:06:14 HKT 2013
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\I���0�0introduction.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: Introduction to the core">
<meta name="keywords" content="Lua, LuaSocket, TCP, UDP, Network,
Library, Support"> 
<title>LuaSocket: Introduction to the core</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- introduction +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2>Introduction</h2>

<p>
LuaSocket  is a  <a href="http://www.lua.org">Lua</a>  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
the SMTP (sending  e-mails),  HTTP  (WWW access)  and  FTP  (uploading  and
downloading files) protocols and other functionality commonly needed by
applications that deal with the Internet. This introduction is about the C
core.
</p>

<p>
Communication in LuaSocket is performed via I/O objects. These can
represent different network domains. Currently, support is provided for TCP
and UDP, but nothing prevents other developers from implementing SSL, Local
Domain, Pipes, File Descriptors etc. I/O objects provide a standard
interface to I/O across different domains and operating systems.
</p>

<p>
The API design had two goals in mind. First, users
experienced with the C API to sockets should feel comfortable using LuaSocket.
Second, the simplicity and the feel of the Lua language should be
preserved. To achieve these goals, the LuaSocket API keeps the function names and semantics the C API whenever possible, but their usage in Lua has been greatly simplified.  
</p>


<p>
One of the simplifications is the receive pattern capability.
Applications can read  data from stream domains (such as TCP) 
line  by line, block  by block, or until the connection  is closed.
All I/O reads are buffered and the performance differences between
different receive patterns are negligible.  
</p>

<p>
Another advantage is the flexible timeout control
mechanism. As in C, all I/O  operations are blocking by default. For
example, the  <a href=tcp.html#send><tt>send</tt></a>,  
<a href=tcp.html#receive><tt>receive</tt></a> and 
<a href=tcp.html#accept><tt>accept</tt></a> methods
of the TCP domain will block  the  caller application  until
the operation  is completed (if ever!). However, with a call to the
<a href=tcp.html#settimeout><tt>settimeout</tt></a>
method, an application  can specify upper limits on
the time it can  be blocked by LuaSocket (the "<tt>total</tt>" timeout), on
the time  LuaSocket can  internally be  blocked by  any OS call (the
"<tt>block</tt>" timeout) or a combination of the  two.  Each LuaSocket
call might perform several OS calls, so that the two timeout values are
<em>not</em> equivalent.  
</p>

<p>
Finally,  the host  name  resolution   is  transparent,  meaning  that  most
functions and methods accept both  IP addresses and host names. In  case a
host name is given, the  library  queries the  system's  resolver  and
tries  the main IP address returned. Note that direct use of IP addresses
is more efficient, of course. The 
<a href=dns.html#toip><tt>toip</tt></a> 
and <a href=dns.html#tohostname><tt>tohostname</tt></a> 
functions from the DNS module are provided to convert between host names and IP addresses. 
</p>

<p>
Together, these changes make network programming in LuaSocket much simpler
than it is in C, as the following sections will show.
</p>

<!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id=tcp>TCP</h3>

<p>
TCP (Transfer  Control Protocol) is  reliable stream protocol.  In other
words, applications communicating through TCP  can send and receive data as
an  error free  stream  of  bytes. Data  is  split  in one  end  and
reassembled transparently on  the other end. There are  no boundaries in
the  data transfers.  The library  allows users  to read  data from  the
sockets in  several different granularities: patterns  are available for
lines, arbitrary sized blocks  or "read up to connection closed", all with
good performance. 
</p>

<p>
The library distinguishes  three types of TCP sockets:  <em>master</em>, 
<em>client</em> and <em>server</em> sockets. 
</p>

<p>
Master sockets are newly created TCP sockets returned by the function
<a href=tcp.html#tcp><tt>socket.tcp</tt></a>. A master socket is 
transformed into a server socket
after it is associated with a <em>local</em> address by a call to the
<a href=tcp.html#bind><tt>bind</tt></a> method followed by a call to the 
<a href=tcp.html#listen><tt>listen</tt></a>. Conversely, a master socket 
can be changed into a client socket with the method 
<a href=tcp.html#connect><tt>connect</tt></a>, 
which associates it with a <em>remote</em> address. 
</p>

<p>
On server sockets, applications can use the 
<a href=tcp.html#accept><tt>accept</tt></a> method
to wait for a client connection. Once a  connection is established, a
client socket object  is  returned representing  this  connection.  The
other methods available   for   server   socket  objects   are
<a href=tcp.html#getsockname><tt>getsockname</tt></a>,  
<a href=tcp.html#setoption><tt>setoption</tt></a>,
<a href=tcp.html#settimeout><tt>settimeout</tt></a>, and 
<a href=tcp.html#close><tt>close</tt></a>. 
</p>

<p>
Client sockets are  used to exchange data between  two applications over
the Internet. Applications can call the  methods 
<a href=tcp.html#send><tt>send</tt></a> and
<a href=tcp.html#receive><tt>receive</tt></a> 
to send and  receive data.  The other methods
available for  client socket objects are 
<a href=tcp.html#getsockname><tt>getsockname</tt></a>,
<a href=tcp.html#getpeername><tt>getpeername</tt></a>, 
<a href=tcp.html#setoption><tt>setoption</tt></a>,
<a href=tcp.html#settimeout><tt>settimeout</tt></a>,
<a href=tcp.html#shutdown><tt>shutdown</tt></a>, and
<a href=tcp.html#close><tt>close</tt></a>.
</p>

<p>
Example:
</p>
<blockquote>
<p>
A simple echo server, using LuaSocket. The program binds to an ephemeral
port (one that is chosen by the  operating system) on the local host and
awaits client connections on that port. When a connection is established,
the program reads a line from the  remote end and sends it back, closing
the  connection immediately. You  can  test it  using the  telnet
program. 
</p>

<pre class=example>
-- load namespace
local socket = require("socket")
-- create a TCP socket and bind it to the local host, at any port
local server = assert(socket.bind("*", 0))
-- find out which port the OS chose for us
local ip, port = server:getsockname()
-- print a message informing what's up
print("Please telnet to localhost on port " .. port)
print("After connecting, you have 10s to enter a line to be echoed")
-- loop forever waiting for clients
while 1 do
  -- wait for a connection from any client
  local client = server:accept()
  -- make sure we don't block waiting for this client's line
  client:settimeout(10)
  -- receive the line
  local line, err = client:receive()
  -- if there was no error, send it back to the client
  if not err then client:send(line .. "\n") end
  -- done with client, close the object
  client:close()
end
</pre>
</blockquote>

<!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id=udp>UDP</h3>

<p>
UDP (User Datagram Protocol)  is a  non-reliable datagram  protocol. In
other  words, applications  communicating through  UDP send  and receive
data as independent blocks, which are  not guaranteed to reach the other
end. Even when they  do reach the other end, they are  not guaranteed to be
error free. Data  transfers are atomic, one datagram at  a time. Reading
only  part of  a  datagram discards  the  rest, so  that  the following read
operation  will  act  on  the  next  datagram.  The  advantages  are  in
simplicity (no connection  setup) and performance (no  error checking or
error correction). 
</p>

<p>
Note that although no guarantees are made, these days
networks are so good that, under normal circumstances, few errors 
happen in practice.
</p>

<p>
An UDP socket object is  created by the 
<a href=udp.html#udp><tt>socket.udp</tt></a> function. UDP
sockets  do   not  need   to  be  connected   before  use.   The  method
<a href=udp.html#sendto><tt>sendto</tt></a>  
can  be  used  immediately after  creation  to
send  a datagram to  IP address and port. Host names  are not allowed
because performing name resolution for each packet would be forbiddingly
slow.  Methods 
<a href=udp.html#receive><tt>receive</tt></a>  and 
<a href=udp.html#receivefrom><tt>receivefrom</tt></a>
can be used to retrieve datagrams, the latter returning the IP and port of
the  sender  as  extra  return  values (thus being  slightly  less
efficient). 
</p>

<p>
When  communication  is performed  repeatedly  with  a single  peer,  an
application  should call  the 
<a href=udp.html#setpeername><tt>setpeername</tt></a> method to specify a
permanent partner.  Methods 
<a href=udp.html#sendto><tt>sendto</tt></a> and
<a href=udp.html#receivefrom><tt>receivefrom</tt></a> 
can no longer be used, but the method
<a href=udp.html#send><tt>send</tt></a> can be used to send data 
directly  to   the   peer, and the method 
<a href=udp.html#receive><tt>receive</tt></a> 
will  only return  datagrams originating
from that peer. There is about 30% performance gain due to this practice.
</p>

<p>
To associate  an UDP socket with  a local address, an  application calls the   
<a href=udp.html#setsockname><tt>setsockname</tt></a> 
method <em>before</em> sending any datagrams.   Otherwise, the socket is
automatically  bound  to an  ephemeral  address  before the  first  data
transmission and once bound the local address cannot be changed.  
The   other  methods   available  for  UDP   sockets  are
<a href=udp.html#getpeername><tt>getpeername</tt></a>,  
<a href=udp.html#getsockname><tt>getsockname</tt></a>, 
<a href=udp.html#settimeout><tt>settimeout</tt></a>,
<a href=udp.html#setoption><tt>setoption</tt></a> and 
<a href=udp.html#close><tt>close</tt></a>. 
</p>

<p>
Example: 
</p>
<blockquote>
<p>
A simple daytime client, using LuaSocket. The program connects to a remote
server and tries to retrieve the daytime, printing the answer it got or an
error message. 
</p>

<pre class=example>
-- change here to the host an port you want to contact
local host, port = "localhost", 13
-- load namespace
local socket = require("socket")
-- convert host name to ip address
local ip = assert(socket.dns.toip(host))
-- create a new UDP object
local udp = assert(socket.udp())
-- contact daytime host
assert(udp:sendto("anything", ip, port))
-- retrieve the answer and print results
io.write(assert(udp:receive()))
</pre>
</blockquote>

<!-- More +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id=more>Support modules</h3>

<p> Although not covered in the introduction, LuaSocket offers 
much more than TCP and UDP functionality. As the library
evolved, support for <a href=http.html>HTTP</a>, <a href=ftp.html>FTP</a>,
and <a href=smtp.html>SMTP</a> were built on top of these. These modules
and many others are covered by the <a href=reference.html>reference manual</a>. 
</p>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:36 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\=]aڸ*�*
ltn12.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: LTN12 support">
<meta name="keywords" content="Lua, LuaSocket, Filters, Source, Sink,
Pump, Support, Library">
<title>LuaSocket: LTN12 module</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- ltn12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=ltn12>LTN12</h2> 

<p> The <tt>ltn12</tt> namespace implements the ideas described in
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">
LTN012, Filters sources and sinks</a>. This manual simply describes the
functions. Please refer to the LTN for a deeper explanation of the
functionality provided by this module.
</p>

<p> 
To obtain the <tt>ltn12</tt> namespace, run:
</p>

<pre class=example>
-- loads the LTN21 module
local ltn12 = require("ltn12")
</pre>

<!-- filters ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id="filter">Filters</h3>

<!-- chain ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="filter.chain">
ltn12.filter.<b>chain(</b>filter<sub>1</sub>, filter<sub>2</sub> 
[, ... filter<sub>N</sub>]<b>)</b>
</p>

<p class=description>
Returns a filter that passes all data it receives through each of a
series of given filters. 
</p>

<p class=parameters>
<tt>Filter<sub>1</sub></tt> to <tt>filter<sub>N</sub></tt> are simple
filters. 
</p>

<p class=return>
The function returns the chained filter.
</p>

<p class=note>
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.
</p>

<pre class=example>
-- load required modules
local ltn12 = require("ltn12")
local mime = require("mime")

-- create a silly identity filter
id = ltn12.filter.chain(
  mime.encode("quoted-printable"),
  mime.encode("base64"),
  mime.decode("base64"),
  mime.decode("quoted-printable")
)
</pre>

<!-- cycle ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="filter.cycle">
ltn12.filter.<b>cycle(</b>low [, ctx, extra]<b>)</b>
</p>

<p class=description>
Returns a high-level filter that cycles though a low-level filter by
passing it each chunk and updating a context between calls. 
</p>

<p class=parameters>
<tt>Low</tt> is the low-level filter to be cycled, 
<tt>ctx</tt> is the initial context and <tt>extra</tt> is any extra
argument the low-level filter might take.
</p>

<p class=return>
The function returns the high-level filter. 
</p>

<pre class=example>
-- load the ltn12 module
local ltn12 = require("ltn12")

-- the base64 mime filter factory
encodet['base64'] = function()
    return ltn12.filter.cycle(b64, "")
end
</pre>

<!-- pumps ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id="pump">Pumps</h3>

<!-- all ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="pump.all">
ltn12.pump.<b>all(</b>source, sink<b>)</b>
</p>

<p class=description>
Pumps <em>all</em> data from a <tt>source</tt> to a <tt>sink</tt>. 
</p>

<p class=return>
If successful, the function returns a value that evaluates to
<b><tt>true</tt></b>. In case
of error, the function returns a <b><tt>false</tt></b> value, followed by an error message.
</p>

<!-- step +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="pump.step">
ltn12.pump.<b>step(</b>source, sink<b>)</b>
</p>

<p class=description>
Pumps <em>one</em> chunk of data from a <tt>source</tt> to a <tt>sink</tt>. 
</p>

<p class=return>
If successful, the function returns a value that evaluates to
<b><tt>true</tt></b>. In case
of error, the function returns a <b><tt>false</tt></b> value, followed by an error message.
</p>

<!-- sinks ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id="sink">Sinks</h3>

<!-- chain ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="sink.chain">
ltn12.sink.<b>chain(</b>filter, sink<b>)</b>
</p>

<p class=description>
Creates and returns a new sink that passes data through a <tt>filter</tt> before sending it to a given <tt>sink</tt>. 
</p>

<!-- error ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="sink.error">
ltn12.sink.<b>error(</b>message<b>)</b>
</p>

<p class=description>
Creates and returns a sink that aborts transmission with the error
<tt>message</tt>.
</p>

<!-- file +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="sink.file">
ltn12.sink.<b>file(</b>handle, message<b>)</b>
</p>

<p class=description>
Creates a sink that sends data to a file. 
</p>

<p class=parameters>
<tt>Handle</tt> is a file handle. If <tt>handle</tt> is <tt><b>nil</b></tt>, 
<tt>message</tt> should give the reason for failure. 
</p>

<p class=return>
The function returns a sink that sends all data to the given <tt>handle</tt>
and closes the file when done, or a sink that aborts the transmission with
the error <tt>message</tt>
</p>

<p class=note>
In the following example, notice how the prototype is designed to 
fit nicely with the <tt>io.open</tt> function.
</p>

<pre class=example>
-- load the ltn12 module
local ltn12 = require("ltn12")

-- copy a file
ltn12.pump.all(
  ltn12.source.file(io.open("original.png", "rb")),
  ltn12.sink.file(io.open("copy.png", "wb"))
)
</pre>

<!-- null +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="sink.null">
ltn12.sink.<b>null()</b>
</p>

<p class=description>
Returns a sink that ignores all data it receives. 
</p>

<!-- simplify +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="sink.simplify">
ltn12.sink.<b>simplify(</b>sink<b>)</b>
</p>

<p class=description>
Creates and returns a simple sink given a fancy <tt>sink</tt>. 
</p>

<!-- table ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="sink.table">
ltn12.sink.<b>table(</b>[table]<b>)</b>
</p>

<p class=description>
Creates a sink that stores all chunks in a table. The chunks can later be
efficiently concatenated into a single string.
</p>

<p class=parameters>
<tt>Table</tt> is used to hold the chunks. If
<tt><b>nil</b></tt>, the function creates its own table. 
</p>

<p class=return>
The function returns the sink and the table used to store the chunks. 
</p>

<pre class=example>
-- load needed modules
local http = require("socket.http")
local ltn12 = require("ltn12")

-- a simplified http.get function
function http.get(u)
  local t = {}
  local respt = request{
    url = u,
    sink = ltn12.sink.table(t)
  }
  return table.concat(t), respt.headers, respt.code
end
</pre>

<!-- sinks ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id="source">Sources</h3>

<!-- cat ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="source.cat">
ltn12.source.<b>cat(</b>source<sub>1</sub> [, source<sub>2</sub>, ...,
source<sub>N</sub>]<b>)</b>
</p>

<p class=description>
Creates a new source that produces the concatenation of the data produced
by a number of sources. 
</p>

<p class=parameters>
<tt>Source<sub>1</sub></tt> to <tt>source<sub>N</sub></tt> are the original
sources. 
</p>

<p class=return>
The function returns the new source.
</p>

<!-- chain ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="source.chain">
ltn12.source.<b>chain(</b>source, filter<b>)</b>
</p>

<p class=description>
Creates a new <tt>source</tt> that passes data through a <tt>filter</tt> 
before returning it. 
</p>

<p class=return>
The function returns the new source.
</p>

<!-- empty ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="source.empty">
ltn12.source.<b>empty()</b>
</p>

<p class=description>
Creates and returns an empty source. 
</p>

<!-- error ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="source.error">
ltn12.source.<b>error(</b>message<b>)</b>
</p>

<p class=description>
Creates and returns a source that aborts transmission with the error
<tt>message</tt>.
</p>

<!-- file +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="source.file">
ltn12.source.<b>file(</b>handle, message<b>)</b>
</p>

<p class=description>
Creates a source that produces the contents of a file. 
</p>

<p class=parameters>
<tt>Handle</tt> is a file handle. If <tt>handle</tt> is <tt><b>nil</b></tt>, 
<tt>message</tt> should give the reason for failure. 
</p>

<p class=return>
The function returns a source that reads chunks of data from 
given <tt>handle</tt> and returns it to the user,
closing the file when done, or a source that aborts the transmission with
the error <tt>message</tt>
</p>

<p class=note>
In the following example, notice how the prototype is designed to 
fit nicely with the <tt>io.open</tt> function.
</p>

<pre class=example>
-- load the ltn12 module
local ltn12 = require("ltn12")

-- copy a file
ltn12.pump.all(
  ltn12.source.file(io.open("original.png", "rb")),
  ltn12.sink.file(io.open("copy.png", "wb"))
)
</pre>

<!-- simplify +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="source.simplify">
ltn12.source.<b>simplify(</b>source<b>)</b>
</p>

<p class=description>
Creates and returns a simple source given a fancy <tt>source</tt>. 
</p>

<!-- string +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="source.string">
ltn12.source.<b>string(</b>string<b>)</b>
</p>

<p class=description>
Creates and returns a source that produces the contents of a
<tt>string</tt>, chunk by chunk. 
</p>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:41 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\��TX��	lua05.pptnu�[�����ࡱ�>��	��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
	@�n��?" d�d@���������  @@``������q�7
	
7%

.

		"$&. 2	0	3 !4#%'/156(),-*+?��$���$��b�$�:@X�\�&#NZ	������0���A���A�p������������@����������N�g*@ʚ;62ʚ;�g��4dddd�n������������p�pp�@<�4d����(����
�F/�0��|�DArial�0�0w��b�������	I�������W�@\P^�\!�DTimes�0�0w��b�������	I�������W�@\P^�\! �DCourier New��b�������	I�������W�@\P^�\!0�DWingdingsw��b�������	I�������W�@\P^�\!@�D-�3� 0��0�0�0�0w��b�������	I�������W�@\P^�\!��
�`�����.n���:@X�\�&#NZ	���PNG


IHDR��0X�	pHYs��tIME�
;xޥr IDATx��Y�$�u&x�{�{D�R+
A,$H��D#EQܴ�)Q⦑4����y��~���鶑iآ(
����̈p�{�Y����6���&��,���2ܿ8����^^^^^^��/�����"    " ��������}�7�,,B9K.��B)�<n��Y$�$J� 22qW��ؗy>��j���f�����;@ć���P�0P8��6g��fsv�����]�cDa�B�9%aF$GEp��������1s#9T���lǩ�v���p\j�Mkmf�u�U�[�VaEۇ���T&��������l����g>�Խ[g;�
P`�>�:�s�L�`�r&bwg�q�%��q^z��v�	U@"N��yj�kg@V�n��ǥ+j{�������7�^#�]�>��BfJe89�o��{�c�>s�4
��@6O���׉����U"TH$�2
���@���5 8Q.�\=™�����m2ۓ@n���-�[���K�/���?{�xuy��r>��d%����P���|���^��K/={�����ۛb��ryy8�!�]]�/��w�@Ԉ�~��Yv�MI��~8�
������0<ܣ��a���䜘9"�:���s@!3:f>t�1���;�z��ѣz8Z]>��m����'_x��>����z��&��w�py٦��x5͵6m���{����D�RZO($��p"�s�@��73@ff�� UC"Dt��4"ȹ0�z�p&&7�(�*_�������˷�駗�����8"�����i�mo�}�3���~�c�<�̭r�%z�}��׶,W��t5/8�q�f���Aе#�{�vL�"��ƌ����D���j
D����hn��J)���B!�C���:: �2y��s}���o?x�[ǫ��j����WXȒ�o?��s��‹���3O�آ9b@�u�=Ц���8O�e����]�.�̙��#�@U{WUED���3`CD�@`DD��f�" ��I�3@3E��0�{�D�ZGDD$"�ps�@��`����~�������G���$���{�W��Ͻ��=qk`�$wV���K]����-�=|�h��n�DDD��4�L{�"23��FĎ"b��*"�H�����#2��,)3��V�t}M"	DD
�nf "@���.���A������O��?���C`���T9�}�/~����K�oosN��\		�֙���o�}q<x�<x���������f
��IU#��W( 1=>��J),��23�C@��!��ݕ�����7Վ���n�H$�(����1!�2
����Ï���?~uz��%�>�/��Oϟ~���o���?���[wv��f���rfuU��r|��w�_,��󬪺V*��@�0�P%�Ƙ��ݯ!�kacB4�,�R2SB@DB@wGrfffBd�X_J]{���k�#"D"E @!@5�)oDDi(H<�����ǯ��ӿ���7_������*���s/��ʧ>�k��g����(�LmDBL�"0��p�����rqq��U�̈́��U+P[["�ufѨn�>zI����݈���x̄���=F�j
��2��A�����Z��F8�sp""A"���[�E		;�eǟ=ڿ����_�f���V�3��}<�1�r�ŏ��_��^�͞��B"�#&S�D�`�LW��pu��4ϵN�I�USg&IC�����H d�!у����@<�#�Y
� �I���
A��C��u%��h��\�*>�$&�ʪ���n9K8�{w��p뙉!����=!F�����wNo=}�?|����w�;?�+�σ�Rn<��O}�7~��ɻ���q��xz���t�aK��k���q���x<^.�V����������8n��a��vs_���P�~*nA��JF!'&r�$���l�7��!�!��S��vtS""D<��RSJ"���NH�����f&����/�AU�)���sJ�R�U%�T�����q8v�ɛ�������m��x�q�ﻊ�,��w^��g��/��O1Y�O�n���?�ˡ�Z�t��Ӿ�b]��U�k7��f�j�0$bD�0w&F_
2a���#�1�H!@8!G��g'CΧ7��t|�m��і��)�-s�����D�B ��ED4w�p՜S����w�D��q\ju�`��&�'�w��'o>���'�������l>���#��`���/����׿���
��5�5T{��2_\<�����j�:L����q�3�O��T��)̣�ֺ��ںu
$�%��AAX8B	xX ` !rJY��-��������uѰ~~�#��p`��f�X9|'F\YSUDBsp@7\ɭp��@t׈��Q�X�ޭ--\�!�v��ɳ�w�*�<�:�la�`!Qޝ�������[�zz7�����᣷�~���qBH�m��/]�ZK������,K]��s��F"�`�Dtm�#t3WcbAFBr����  �#�$)	!CT�~��ؕ�?{p��gڧ^�V���#�J��H�S���|QN4�K�)��J�y)'D
$$&$)C5[�Vզ֚j��o�tc>����?�|�Σ�����}�cQ.7�}�_����Ͼr�f�M������|���:o�O�|�{7n��G�����e�ͭv3wPծ�Z;(H11�J�ݭkwsB�� $2��$9��0���&DI�'I�(� �lܔ�j�����T��\&��պ�$�轻{�2"S�i3�4l<��
S�ٲ̽�͸�H�����:?�xt�:�*�o7���ӳ����O�Б�o���������e7��슅�۳>�[�����#��m����?��k��쪧�x~z���QT��q���狇��f�DH��H����֙ q����������%��Q@Ĉ�B��A�,��f�XY�:�̂���S�{�yx�xXW7�����u�H"E��#3�D9�03��cɉ7C�Pr�PUpC`⒓ZÀL�-��;�}���x��~܇ٿS`!��3�}������G���H�xyq�ξ��y򅏽�̽[��eY�4����j�T�U�##�"��#H�����ק��D�HD�DD()%b�`�X�����0�� ,�憀9e"333���{@DfFL��ɜ2�p8�R�03a�0%In�H%ᄀ)�\�;�Y�b%h�n���fx�wOܽ�vy������4`q�x�7�����o}d;�yCF���O<��/<{��	��|�Z�һ>x��oܿ:�����x]��Ý��3'B�p������u �pJ�N)�9��pͣB��EIBbr�ֺ�  !�9�)�!1�03EP ������q��p%И��,�'Ffʂ) Ly�|���*D�|"���|�ӟ~`���R�V�?�Jۓ�~��o��+/�31Ax�j�P��0�6_]�]^<���8����C]i(wǮ�n���DXRJ�6W��؄���{�U�񈕂  "fD"�p$$$!��`�X]_9sʉM�w� �$���Uv&U�5w��@D���AD�K"�R21v5$L9�R�zwr$dfN��+���P��3�$1���2�>�=��s9��Q�z��8���W�;�����-�*�"�i��W�!R]�puu�������j^���w����u���S�̜E��&�zT"��D��������J)���3H�9%�0��q�a���^k�KU�YWu@�w���g� B "LYZ�������p����	�,	A�����䒶�m.���V'�p�`!D�9�Ͻ�L��z�qyt?�>��"�<����_~�[_�ē�#��X�3
s��j����?L�4��4�<-����LH�D�BD93�Z�D��"�@\�fGD��|�#GDdJ��>�,��<��Y�sE�R��n6ϭ���EW�
<z�ں���k�b�!�2Hʨ���5�k�uYz��R��z�^�qr!���sX�@a����n�%r!��q��zo��(�w7��^x��K�x�~=<|;���D'O<���}�����v�,�uYP8ֱ�j]��.K=]�j��iZ�h��k��dA��$)������Z�����_
1��X��3���\�9	�0'��DD"��9F03�^km�����[X�f�~��$"g BµϏ��{�Z{o�j�][�V[_��RU0'���8I���,%Sb�yv(�y�ֺiw뭙��RI‰�����u�Գ��޷e�`iw���ï���}j,	�5�9�z7[�m�vs�e�k[Z���<MK�؁� ��v��a�a�]�Y���`nfj�n
�,�HD,¥df�\���9#�!CaDH)�R�0!,s�nnn�#9	�{W7wbL9��D�TD	VG��p�@@� 4��go�Z�+j{�P#@ﭵ:[�ݺ�%��f�����DD�0�"������37wO<�҅ѻ?}S��,�r���w����|��F(�C#�k���n���1��p��i�S�v8��e:.��D���
�v��T!���)e"2� 7CGL9�H�3�v�J'7cN\$�;	���2�B(1rRJ��k��E"��P�a����{@�LF�\��g�W/3K��a�D„�x=�a���5%f�����a��������[�3 3JI�nN�M[%a!NA���$wn�y�ŗߚ�k�F����En}�?���^�-���g��2��犩�qW���m��z���p��e�&ո�Ԍ�W�8K�U��N�����צb""f@H��>e�)"��3'f�`�a9���L���DR�%�޺������9���v"`&�r]6V�1�l�!��"�V�l�!K�Ldn+i�’R3W7D�U[���Ԗ��i����V!�l6��	`H%���GDh�(� s�ݴ���g_��Þ�}��S;�{,�t��O|���g?qbJ��.�����R��lܝ�"�tX�4�/��.//��sνik0�YD�2�d$sU�P�n�T7��"��AD��l�P$�ٌcJٌ�8Y_u(��э�p(���i:��a꭛vRӕB���,�N������b�����������<-"!3qD c���zSU7U�fq@r��4��a�H$,�zm���ʡ8���Cx�t{��}��7�p��խ�Xg�|�/���Wn��)�ֶ�Rّ0`H.����	j���Η���Ԧ�„u��@�p)eSƕt6����"W3�:��P����@p�َ)')C�m��fS��%��Ą�j������4��󴴮�lfH�,D�ی��5:�# B�!`FHbPuG��]��L�a�nHLĪ�zw�=�XD�]�0X�6UWscbHX��V�}3@ʔR� �(����>�ҋ��տ��g��g�:����_�/��gn�(	a�G7>�u���$�[�2��0�/�|�z���ñ�91P]�ei�NH�d�0���yV7O%��5f�ja`!9m6��n�%���vۓR����0l�}�ͫ ���$�./�5�n��"eܨ�Y1p8 A�$���?N��@��jkha+��{w��5�ƃ"���T���:W't)eZ&��7D�u��݈u,�pF&`̹ `mK��29�~�􉏿9�;o�f�{�"���N�y�w��?��o�d3��x������<P���4�ei�|u�����p�q��޻��*F����!@�š��G�J���x����$�ڃx܍CNB"��v����WS`�$�����8��A����0�p�@dvwH%^;��=�Y$�X��Һ�#�#8��u�u��¯���=���#, �����
�f��!�`N)cÁܬ���Ū$dA�7�z�Q��������p���W��O��k_|r[F��8R�5�N��n�Y7b�3U��L�_������l[2�$B��_�.�ڻm7cWuDR
5S3bRS3�@�Ļ����Iz��4���X�X���M�{����$�2�Km�B�y(1���P�@s�\�23��jG"$$�uHwW3�`�257u��yZhjf�aq����n�[����f�P֜b@3ϥ0C0�C!#�x]7����p��So\N����~���/X���g��;?��W�9�<���="b=�]�z��mAD���Ah)�ӳ�P0�-˴���.��j�譵�Y$���spbp7\M)Ev�MN��%ao6O-<�HJ��2��Ҹ�M����:�9E�~
�2���f��u~�f^rF��%'fƜ9�"��,$��7��KVF��׷�rݯ���S� ��p�^�=�����0#������3Q9??K�<^��U73o]ͻ�y�vuS�6<@x�qo7���_{�=z��:���_0�8�/�w�����CFvbN�P ��="z�n�]��>S�4�H�y���tu�����E��B�Y!�9��p.E���KN)�D�Z{8f�F9�l�í[�w���D᪮�Q[���0-�Ń��qj�̌$J�1K��ڎI�s"��3B�̩� �v7��� B]Z��̐(�XRJ%Ex��{�u��@��ī�k%��z���M����f�2��@@F �`���ֻz�E�n��4�#�z#	�ݛ;~♟���ӻoA�X��ӟ��w���O?u6#��ǁ�V����ͬ����L$��<��Zs���i�JY�K��
���"i5?13"��Cɛ!1���;"��&e�\n޺=eS�M(�׹��.sWmM���~u8εj���*Gx��;�ڈh�l�XD�����yѮ�����)�V���t<L���z'���zS� D@ww7bJ��Z5�q�����F4��=������]6lFf&�0w$�p���N,"���F�)�n���_}�^���j�a�B��>��?��_~v$)�f�%���ڑ(z��ޭ��{7BJB�`��r�_]�K�O󲴥�U.C��]��_��y�0B��X
�'�pw������1'���t�Ɍ�m:�y���0�е/˲�fL�wU��$s�<�Kޞ���M"N���CNIC�x�j�p5mB��ԛ�"�n�ī"��da~����D��E2���Et��ͬkW��T�iO�� M5�K����=�3�"<"��INo�ymo�_���	XD�_z�������@��0����nv����[�֖eR��ZSS t�Z������qJ�].�{��%I)��91���a�X!,�[����X
����I�y�4	������q:���yZ�e鶴�ĭ7���#�P�H%���mv��d��mO��������0��p�]��(z[���u^����Rr����j!��*��-���#VsNo}ݥvw@�Uf�d@T����nix���v��S�k�SJf�K�=z�1�CG����͟<��z��Wvx���a�},B,7n���÷����	�R��f{����[
W�Z�-�M��nH���eYju�n����v�sN�kJRJV��\	�l֙>��!%�v61�Et5s�@ �����òD`xwG`&�5l�γ���'���sF���CJ�ͮ���RJۓ�8��{��D�၀jf8����0��zצ�q���k2�{0���*2�+�� ��:��c���910
q��3�EJ�R��zm"���� IDATX�y4���8n7)˺�O,�RDn�����������M���2�������AМ9���|�=K�:i��y�p��[�n�a���x��CNRY�b�:�pg�Z�Ҫ�3�je_ap,�v� BW]Z$D^��$�P�p�JBĔ�!���4�k��)s&�)#�8��6�"�0�$�n��Y9' F�P��Z7b���s��dD���SL�D���C��V�Oo�(̉@c&Bw'ND����eM,9��4119JZ
�LnA$f�a����e�XHœN�ݽ�ԛF���v���
,�t��~�/��{/�9��M������y�>χ�fj�w$�}i]��) rN��s�a-Jn��$4<�3%Y�&bs[�9d"p�wd��Y��d��}��f�6#<�b��P��	�f,��n���������QX�T��͈0�DL@�KwE$Ja�r���̫�S��pJL��k�| @N��L�E " ��YX)e�N��(�B�ٞ��3+B�7'�J����~�`��!��i@JNBL'�gO�}�jy��Z�D`���?��w��ffS
5Ne�CI�K=^N��#<L��l���;0���)@�9!��!H̄�f��5�����׊�"��գR�Y��\ �	�!	�p"A�$��׷�J)"�fI�u����Pi�a�¹���øA���!�����]���̽���y�{�ua��p"�m}$!B0�@`&�^B|,N�.4C $B� �BL�]��2O�R-�o7�7;岿�U�ę�m�l%�Պ8�l(�,�r�7����-Y\�`!Rί|���k_�w2@���%o�,f�.�U��`�.�~��i�DIR�Ǟ��.�2IB�$���l
�2���,];1$JYݗ�D"��)	'�̔� ���7���H�َ��Z�(���1�pJ�$]/g�!�cu}�^kE
�һ�
�n1M���*Ϲ[���� ��ZzVS��� 
B�ڳ{"##B�Y$1���c�;8�XDdm#�C[tUu�
�m��n�n������#X7 C[y`"a�)�P&Ι�ݛ7���o���@��$��'������lE;#D����A�ZW��5#$0�������E���B9	3�":����%1R�l��q��6WU�L�Zk���@RJ9��z���YJI��j�6���lY$I��P���33y�n��Í1�$L"c�["�9eI�U[[�EU��)@i}�:��z-'`Ax'\�b��憈�]��;��i�~̮�)����%&��]��P��Ú�%]uM��0)�l�Hތ۳����t����*213SJ�s1�!��R�B�p�t�ԝ�u���H`�p�ɯ����/�����%��L{k�"81�*D0Q�O�N�}�a6����̺5��*��\��R�"O������ë�ü���,,�Ӛ�AL����Z�̼�l�y���j7�k�-���|�UU�F��d0ssEtS_s���2�%�q[[km�ui�]K��"r~�$�ܛc�����{�~}�Z�Y"J«�Â��R[�k���8�,�+щ��N!��$э���ӓ�y3��R�"��y�+#0��j��$g����&�I>��~����g�Z�����/~������ €��]�T�:��&w3�ޕ$K*D���7��XJ_f�j�A�E��)�
mY�}xqX���uzbFA��RJy�-Ih}�Ă)	1�2k=H%�UU�B
˪ծ���$I�9�d�\sk`�N�!c��\����Z�a?�9���Y�v����jm�@�{[Z���ǜ�$Ɯ�xaJ$�D�AI��)�֓�)�Q	ք^7"&َ�f�i0zɖ8����Hn�]U��z!$I%�,�$�$9�ɍ�;���'?�����䩗?����Oݽ��.�a
�t�5v3b�`V�)�m�s�R�{�ǔK.9e1��;.e�0������S7'BD�@$Z�89g꭫"���d<;ۥ�`k��Jk�'��ı植cZj�R��u�O�03y� @$9�2 �a��MU{�
�jfږ����x�唺v�w5�X���0�q[���B����=,�	R�,��&U�ʞ�*�1�Hy�6�[���S��-��s)�����s�6�f([pr�H\L6��ُ���k������o�q�s��������SVՎL)'�I	֔ �u����{���S�s��Gߝ�9�%���f<n7�Q�bͮ.��	��u��n`n��)�f����n1-�,��ؓ0]=�#@)��Q)I#S���:}�p�"�00qʒR@��Ĝ$!r�h�vc�!��lz��FxJ�s��)3'y|ҁ�����8g�C)C&F�$,ִ�n}���u�w� "&���0�;�z�!c��&%@�,n]Q�Y"�x��em��2J�,�v��cN�C�Ӛ<MI��x��n.)�Ï^m���s`Q*/����߽��!�Y�H$"�z7��8Iʩ����a�a(��r���~��Z�|uq���=�X��(Q
a�u��IU��i:.뷒L����		S)�tz���l�Vs"^��d������0���a��@��{x0aY���%��(pJ)���	�R��vG)3��P#a.C �ɶ+uN���Һk���_w�̀P$�������f����=ְ̜�_�K:�\�Ą�@)��f͇�j��0�4�w/�4%)�20",K%p&�)#���4�
�4gޞ������װ��ǻ�ɟ�7?z��0ppQ��S�NR�)�16�����4oNO
��xqq����b�u:·�q:NӼ�0l9Ir�e��.��CD�s�Kh�@�ی@"@^�@=8
�8��	� �������մ�qːY��f´ǡ��RJy(1�e2W�룼�awrzrrR��0�����e53&\i�u��b�)���3��H�{k���_��׽�k���7��CA�E���Gںwuw��Yz�f��H�݀Vsj�h>,`}s���j�aJ�9���HbI,"�ER)�9�D����zq��~>`Q_�—~�/��)�hkh�j�9q��h{�˒�o]#�>�̬����g�3��&��!?��@��?��6X�-���H�W�s���<g���Ȧy4lZ�K�
��:�D�Z�~�e̙�3_��y�-���z=�s�}���z~~���m��
��a��Z���?�����w��|��6lD����d�u�@@��‘Tʩ�p�01�\�D ��ee����g&�f�E�S%����pG�H��2�íH�\��e�0a`���nB��>|�,�����9��˲,��Z�����9V@Ra)��	��x�
w@@��fӢ�H$<4�$�q���hQ�^�͢K˵��	�.Z�A�8YZk����zQԥR9�T���PeQ�X�o~��W�c��/��Do�����o�ǒh}��=3�! ��*�udY���xyh�g����d�~����?��vߏ�h�O����0�Z�|����w_
���\`��,`�f��̢����z�>~��/O��>c �~���y��™����,3��‚s���2�������R��T�Z�2`�'i��[�^b�!<�DH�"�u���<��0�ȄD�p���|�O��,�	-JH�.ATbL�ʄ�{��QCLfZ��F�S��yY���Xz�����!�q�����[�ׂ��D�X���=NO�_���O��/���%�������←�6F��A��(\J!!Y���qx����i_��O_�c;�};�F�G�{�Y�6�3|��v����s�~�\>�����2Z�o����=$D���KY���.af���}Xw����R��3���������e�F�	���9Zu]�Z	�Y�����Kf��	��K�X@��p�>����__QD��^���N�,6��:CG$fQ�9Ł�����y#�̘p��p�9gI��?HYEj)
l��1�)�Z��H E�����BE�6%"���_�������.,ķ���o���1�#��0Q2���û�@��ZTdnl�{�ll�d���~��nc�_�!�,br<<b��̀/����1G�_��j���ᑙ���ʥ�Rϥ�0s�G�� �,U"b�S,"�	I����eAT"^��$����6"��7W�Zt�0�h�߽{yy������.�K)��t��HS)"*�LTKHD`bd�O7s��}t&L�I�ԙe�|}M8ez�$����P�p.$�uEY���$"f��l[3�"�L��RN��j)eY�`L�Ia����G��'����o���'����yS
!!�Y�«���vG-k���rւ��m�J)۾������?���ָhf&�%�وD�E�1<l�Ha��?~*B������5�GDD��z�^ψYK}||�^ϪD�@�v���ưu����e���ZX�����rzxxTe����e�#'fx?ھ��c�v��{��Dc@=23�Ч�,�pJ�>�}'��U#)"�W�jΉ�׀��HL���:sO@�̂8)�("�:��"�	>�DU�.��3e��&b-��3`�A„�B
,\ʊ��b�9��LE�t:�����_�F/�o P�|�7����z��0��9F�.�*���ᑨ,��Zʲ�k	��޺��!�c<��ɂ�����կ��*�dU&��H�����"PT&Fbe��~�z���i�`˲��}aB�0�(���&Tx��6`x�gHpߚа������lDr��L�Ü�X�@pH���k$6�����=�2q��3�.� 
"��01,H������F�y�&Af�Kb��V�E�zٷ�"�zZ��<��.K9�D�Y ��Gk	�y�`$
�"�'����{���?z�����K�Ya�|���?����T�8���p=K	���.�e&€"Ykm�ALZ4!Q1݌� `X�OxPR�s"�;"����R���<f���m$$ե���[��?�����mX�@�p` �jU�}?ƴ���9P9��Dz�F���pFX�=�(1��W�7�0������D ,3k=Ml�eR@`��k����0i�Ჵ�ĸ����!_��I�h��P]eD$�y�т�5̉�^f��R	�BPד�*�.�b䎄:�}�ַ@t��$�D���.���W������~{���*�����3�tٌ��棏��[�`d��%!�1F?�r�v�����y���ю77@t�y�#�ja���݄�O>y:-���hH4��,I۽o��eX�D%7o{��`�h�ef�2w8�<�d6�8,��"�}�`$6��s~BU�LC�p�W�'�pQQ�LD,�ak}��Ɨ�ED��f=�gЯ����V����u]`��"�j�\.u-Z��q^����̬Z�)�]��1��U��1`��$A��m�Ѷގ�D�:M���>
�'������?˿�
������������b���Z��h{@d��+#�겜N'������~��ɱo}��"<F�d��01K�������e]���Rp�nGk}� $-e6J�7@)K���>���'39s�}�TfR�L����GW]�1v�H����r�# 
=�}�k231,2�5(�!2"�Q��ϑ��C�RkD�1�a�ͭ��Ru=�ө�E_[�R_���A�)�˂Oo�RkzF+s�I�Wd�@H�tp�̺�eY�/�2}e��ɷ[���~�m��P�L��
�3��+�n�{�i�������8F���
������]�Q`)����z�L�I�K0���~?z�{�Շݺ���?�
Ӛ�m�)f�o�R���ͥ��ֲ���m۰@.S�Pk�a����"Z0�����Je��z��ɛ�?���w�&"絞J]u1pfQQF��֚J��m��ӹ���+N O"L,nDk����{4s	E��4G�D42�-�RDO�Ӻ.Ȕ
�!9�{U\
�G߶
1#��e`"�\�"������3'fB��G�Y�s�2OI�0�3���C�3e�2eZKF�p���������~����_��_���4d��O��k?��uaHL drC��~߷��)	�cx�ì�n}�Ј��R���=2<͆
^���o�>=>=�˾�>z�k[n�:��0T�T=�!�6���8��A	��ʹ���-�.uY�2�y�X���z93���~�������8z)��^<#"12�Tѕ<^���qz%�`:2�`)�30���S��H���S-"%3Tp��Z��	9�<�^1�gJ��*���|���u�؎
0���뙰Z}��e����.Ky��3����0������K��(�������O?������/?������?��g��0f�LGV6k9�=�d�����m�7D��Tsێmo=�)g�>�^d�~�`�����7_|�����h�龜�l��뺔RJo�拷�v��Y�=f�n�$@��|:��	)�J0�=܉@�JX�E���q��#�Y��a# h;Z��}�'��~,*���A�����oS�"��r�_֊�������2��íaGDL�p�L��S����8(�N�07�D����
��<q���׍W�_|�>80��I��)><�������1�"���[޷Ai�E*M�ؠp�Q����{?�џ�/��ҥ��7�Χo�I��c�(�h���zAL���i��{ג�B�}kH�\���L���}����Z�@D &R�uՔ\T����z>����@u?���		"#���Ӡ�������R��3�Ta��-���{��{OQ���$NPUABB�)�"c"��}�_^^2�
��e?��8z���im �RxYtY*"2R���x���#&$�H��� ��R��pwָ��N�Y�����L��I4l����Q!�#`
!��d�j��+�m$�xd��~��[�o_����������~�璇0���<F�ÌGo6���1#(0[�������6��GS]
 �����(KM0ԅU��ض)E8��ckǺ.���GN���G��@�<�3��rN�o�_�����2��ڼ#2�.� ��H�9��p��a9ƨ�� 콥{�^��L�%�f�����|��`��[��y�\k9�]�Q�[�YCD Q8�0i!�H�E�2E��PI�Kq�����0A#�DQ��7"dE��4��
K-r~��0"GfRk��(�3!Hp$�a�w�,L�����S����z�������c���
���׿����5�zxR�[���l"�٘�"ct��n޿�	�B�nc���tZ���L@!�R��>_��Z ,��裏���2E���R�u]���>=>�N+[�鯉z�Z��PT��z:��Rʲ�ZDH�@�n6�������T�%��m�Ѡ��3pr���M��4�D��l�g7g���E�Z.��C�����&r&Zj]�5���=���ȉDPTX	I��"#k��\��%�N\��ry��>~c�1Z;��sMD0��{C0@`��z.��#GoBH�#,!�ɇ���?k�_N,9_�����s���05���qt� -��-���}�,�0�y�K��e�x�j��u]�E���mG0����F��Ƭ�,��VVf������Z��֚i��h�!��]T�03��$$R"xf��!1�nn3���fƬn�%.*2��f������uy��'gL�!"�c�7!~x�V�yk{���[�cQi-��U�!^��ZO� �ZTV"p�n*R�Ek�G<?�D�!>�����ȵ�<�I��H��m좨TZ�ᣤ2P�q cъ4��f�a5M IDAT��F�:V������|��������_��	'2:��#R�ޞ_n�弞6w��
B�t�Oժ�I���� i)�H��,��� s������sx��,��҅y�mYJ��hG��^�x!Epz12òV��uN�ӣ�h�4>�>܈��қE��'��)�i]�
A@x���"�an_�#=
'�jF��{[�
�DUϗK&�H�n�
$	x�]Uܧ�{�m>����	��(�L�I�LYT�v�ևar��Z�t�I�CFxBf��я}����p9�����3Dz�a�)��ޏ����#�[��<��}������/��o]X�ɯ|���O���A�}��^v��4 �03��8���K�ݗ뛢�|@n�r�^ͬ��	�#��r>/c���O��{doM�R����f��}�ݣ{;��8���s��1��eb80�Rd]�T���L����R�c�Hp�#�}�"�*��_k���l�o; =<<�~SfN)�+2�^3p]Vo�Jo�.�i�wF|��
-K}x�23G�Y��D��1Mф$��D*�	e��2z����i�j$QY�zZ,K?<<t)�ff0ݶ62,[G]g�JcM���^�#̥��8�(1c�ߎ� ��I��w����_al��B@�˧��R�F�R41}��c��B"�gbR$��1�,��[�TF��v�\H0|(��"<}$����SQ�������#I�
&�ގc�����c���P-����ts���,t�����tZ����l�G�L��m���Z�a��|�}��U��AȐr����o�~4���i>TJx��pzfZ�	����r=�R��|o�B��yY����#3�e)�dv*4lX�ۭE"Z"13K��� f7��#_zDQJ�Zʌ��ywS�T��S;X"��d��_�1�#ܦ���'�{o"�ʅ3�����o��s��I��� 2��ͯ|��J�aݺgBp�u]��2	��Md
���$E�o�g��P�-��Vf���EŽ�-�������PU�qo���R\D�*J����H���+��}YW"�H'�ea�{�Z�R��6a}��v ќw�ψ�����G��r���^����G7�`���EF/Rh�0#b�0��,I/p�.ꊌL"��"H�P�f�љ	Y#�Y0C�P&�S8f�0�Y��%�")��:���ɗ�Vٻ��c�� B���3q?xf
c"�7O�@�D�f4�N���>|��W��+��>���6�F�K��*��9Ik3���L��c"��j��	��	˲0s��\�˚�f"3Ͷ�ZJ	�qusY�R�U+�Ø���߿�"!}:��54X�ZO'�w��[��!��0w���25�6|; ԥ̅�R+�6]������2�}�62���!	i�Z����}�R�Ǿ{G�<�/*���L�1�Φ�R�Z�h���>,�Z���5�e*� _���
�b)�!�m��Ē�jDwD�Ha^��[zD� ���N&�y33��E9�1�ˇ�㗟�����i����go�8�e��#8��J\kEi�>�SY�y��Q��SA,Z���a\J	��r�XN�����{F)\����W�ֺ���O�e%��[s����ǧǶ��~?�;88�����V>�D�@�X��|����/�[��mt ���-�+#�1"#��D!3�HwU�=�HEe~��IL�J��v�~XD$8@�6*3�U!����ZY�F�w)z��T�$���X��X�ю8�MH"2�2�`�>��\�Lj���c�JEN'"JGOlG�"f��,��j~���m��,�ѣ�>.�s���5B]����>Z�~��?XO��L�����O>���zZ ZOBf"rK�4H4���lN�"��Y"sL(P)�ƈя���v�}om������.�7���E�r����5R�U|�9�� ̉L�`���=h��@8_N���@�Y۶������Y$!-��""�DB�bd��A@B�9��2�0��gjf�Ց��iG;�h�APj$���JJ"�$A @r%Rf�1�tyPe)/J/����M�R;�Y�}�7�
��r���˺���i�"I)u9m{�ы.{���(�U�����>���{�eE��$p�H��Or����Z?z���V�<}��� �6�4f��B��ov�%�#G�;@]jEf��H�Bb=�,gvC������f��9z��5f���Ĝ	�5"R��6��v73�D
!D|E&�>8-=��}b���Z�� 6��|Ǿo6#��E�$e)��r>=��i������{�Zk����,��uFD�iY���˘4���}ԡiI9��N�uo='�Y#��F��z�0+b��
����T�yct�h���e�
D���t�> *E���eaf�1D��L�:s�[� ,PJ�RQ��ix��H'U}�������c3w`]J��o�NO������qa����
پo�6Z���J�h^���{���6>�c�����}���z�X��7R9�yZ��haD�$�"��� ���"kwy�E���̑P*-K}l[h(Y�><<=>|������޾�p#�"3Y*�R���͛7���F�Ҿ��~ذH��Cbc����/��މRX�dJU���:���:�F�J��
�`��q4��`��z
�nV�R
�G���T��JE���)"����~?2�
��뺪��U��R��i�(�O�3fd8�h*hTb!]���Z?�UX���z�ǡ�0�g3a��x&��;j|��Û/?���c~��B||���˕��kށ@���B�ZD ADZBO�! �j!H~��Z�2ݷ�c����J)�,Z>��3����ֻ���`��C�aJ}tD�H����܊���vc$��.Oo߈�z�cߎc���{D�E�ZO�z:�j]^��U�	��Df1P23�֞?|��Rt���R�S��.Z4 aY��;�WDL-�@� �1��m7bzX�p߷� "��$e��DZ��6ɕ5��׺L�D�a������)��Rq�G�	���M���A%^ץ��ۇHjm 5]�n#�4����DP�$!��n���v9}���������\XL���Ϟ֒6�1:�'R�Ya�ޏs��"�DB��4+@�r���g=_�m;�����p�u�s�2><�щ�r���v�؎9�-ݑ��qߎ�(Z�5*��l�d���o��
C|}M�m)|^��ÅX������}t"I�L�Z�D�L�p~��{o=<.gaR���t:]2�ݙ"|]�0DP032F7����
Rd"°���b����6�Dj���n�����u�!�&	bX8��vl�$��)?����������sxo��a�7ƨU=\er��|�v? 2[���km>l��e�����Z���nᔰ@~��h}�oRX��ӧ-��c?�3����!��yx)�(!&"U�����Z�0������J
��{��UJa�B^N���L��dnct�62���{�E�b�#�i@���m�H��z�msO��8̇�@
�	 ��[K3�Z���f�,�Xh��lG�H�8?�Rd=�j]�۶owa�\�"����.$*z�>U�C F�R�#���L�D X�#�%|��l��*A�ss���c8��c��Id�؟.DZ��)�o��E�,��T�"�4FyDk1y�I	��`��CQR$�&K�(�!�}�-)ž��]�_|�D[�1�e��آg�n>"��j9�ZuY��Xu"V\D�Yo���hB��iQ�<��Ç$nic�1�O�t�w?{�3P���qxx���y]`��
����"2� �dp�f�Gs���+����GzDz�#@d:�7��2���\�����^�˘��,��U���C�E��d=]�:E��o��h��h\=��8�_j��E�Gov�Z`���ed;&�oY�G����1Zǁ��c�r��K����}��,瓪��<?<�R� @B�1��`�je��Gk������Hf�����
1J$*�I$��J�����={��Z���Go������NW7o�Az�E� �jUV!BĂ��"i��FJ("*���J���=3!<��,D��eYk�=�HpD6����=���`�	#��B�)	���[�'��G~�}`fRY����U���ZP2�{�e��/��O����v@�����-̵(+�t.L���{cL��ݐHKB�v@�Y��)�úgd`t��UVd~�|ÑeU3����
����~��1��ܾ�R��ݼ#80q$u�<��w�w"T�s�"���/�K��uUR��D6�����u��a�>���>��D�%o�|z|{#���,�-s.$#KeaN�c8��hR�D��L����$0�2��)Z2��*�Z����[��T�U���q�Ç��[ocR7�LyY�f�z�"2�t萢X�J��9��9$�EL�,U�"'h�uYY��"�[�t3�Z�u�,��W�m�zۙ�� o`�(�t�ּ�d��є3�82��,E��=Fb
�+�vx�g��n��[���~��a���<?zct�3��"���:�ԯ��ʺ�۱m��=<,��UdE�K�1"b�+/.
��;��^��"�8zj},E�Ā�L�9��ѧ?�������>Z�q�J�6"_��QK}��D�pD��ɂ@��̷�
�����e�zb�O��^^�Y"0��zZ�����x���[ks�L��Q��E���2SmXO�E�U����0��b#�f����!�n�\�I��]ǘ�f$��!a"$|e��~�m����L)J"R*
�[�0b����m�ˆ4��u��j��'"2��c����}�c?l桅��q�c�f&"��i��zM(c�p�}@�	 ��-UM��,ƒ�^�p�f������{��HD�.�v��	���f����G�������%ؙ���ϖ��/���X�O>�0��LL���}	�PΤ\P�h	��h���h)�����‘�H��l-�u%�8�Y��t}z|�?�E���ÚE�N��_6��<`=����>�}�c�+�ZֲD�H��u]��k-���rY-EU_Cu�&��7ό}�60�e��q4�ѭ=��P��̿��0`��V&R���zw{q��5�Ù'SgNV#bo��L����n�V��͛��Tu:<R�F�b�����L!
�1�lQ�3z�����A��!t"cX�B
"�D11��Ԩ�QGSR���D���Z��ȧ�z#����=	?��qADK�]���"My!�aL�L���**�a�3��$���c�dB&�9?@'��TY�qֲ��e?:1i)�~c`�2�+_߈�E� �t&"D� l�Z;���j�zY�۱�a^�%����D�t�~��Hf�d�'d;��
"K|ʏ�LB��} !fTb�������6�8�1��
�-"	_c�ƙ`������ڶm�}t�ׄ�@$HB��%��;C�
3�{��4Ţ�4��޻�2#_�����D�}`��	S
�$���c����PL-%��|��I�W��/-,9���X#	�t)ٷH{�8�C&���s�Z����p33�B�Z*�����y�6f:ڄ�"�O+	��3��\ُ���Ah��Ԝ&!s#�&	��CD�e�dD�a��$�f�FD@�3�iJF�{"�XDȌ�ݾF���; LX�D����e}�ջ��U���އ{dF�������C�6�����0�Ӻl�>�m��1��fSH8�@Œ �?���
#��5l^�w��c/��ޥY�%��[���y����9�@�6Y��4��)2��M6ɮ*��̈p�
<QFE�1�Ɍ�p���y�G��m�ŜA�9ӳ��X��&�`���X��e��?*��m�S�	���fo�?q� �/�>��H$'���+�y=b���oo�1n[۫��X�GD0�2Zk4��9�'�$�;cd�u�ΈKڽ�m\c��Ϗ�u;��_~�!`�J!��9���m3�D麎u�Y�9'S-���_c>�8����8}<�co7��fv�5�
_�e���U��2A{�Jg�iT��%��Ͷ[����:�_j=��GQ�#Kh�_�H"��c�1�T������F���˵�m��y���όb�@2	@�@$�(B%Mܣ���A�\(DpB$�� T��'ig��#�>IY�1�38P�F�{k2�=�g������Mw�"z��y �$���	����?X۶�n�Ef�
f"V����z>g�~o���+����o���QQ2Eb�z�B1S���YU>�y���*�U��̠�����Pշ�7��xΔ$��^w�V�Wf^׵��ki��r�*,��,�����QU��}'Q39r=���:Y����*W�:9�y��LVc���E��D5��7Ӎ�A��b�/�vf���S��rm��h���uM�b�W�'b�\��b���ʊ �̄�\��Df��z�FDQ�U��U�̜�\E�qf&�C��B��ç/ �l�10�#���ʘ���1D�����s�"��/o����I��J�,B��M�P�bE�U,�D�Q�xs��Z"P��[��1\�n����d��6Ӗᕮ̧gA�}�>$�����W��Y��!��q\Slg"Y˸p�T�@a��A,�f��cp�u^�qfդy[bHQ���]�܂���v�`F�W.������Z'�mﭿ10���:�u�eD��8��JzbR�/�o��|z?�1�じ,���>zW�V>���+ba�LTE�z�(��(V!^i�����٘N&�F�c��T	����(0�{�uMI�ʄW�’$��&i�QQ�~<?@H�u�t�=��Q��s��~���|���j=����,���e�JU�55S��!����yr�I��o�<�Ǿ��+�Ĭg��Ψ�xT��ITbz�Õe���#«@�&��[�b���*�!z�����~��1�1�Jǡ������}�o�Of�*��<F�PU�rw�a��V�q���0���JS����h�n�7f������y�<��DѨ����>լ�+���o~�ӯ��_�_���-2E9���6}c��8�irF�H� ���V�T��"�~�3���"�f������qxDF���u�*���Z�9��D�3�Rj1U��UrF���ӛ��k�o7-�`-
D~�ͯ�ݲ&����\����d��δ�%D��J��Kx�Z9�&�RUI�9<j�m��۶�j�{8m[���ï�T�Z[�90HjΙaٶm߷}�32��oo�����o�y>���(0��m}�r/�"Җ�|-�A>�:H_�PZ?3�")��������E���o�Z�y��[�kq���>�R3�9�rߵo*"}�*Bĭ�����X2.c����<.�)FU%��3|�N�EE�X&+^���Jd�
�yx�}��5����(���m�=d�s�t�L0F3ɦf�i�#+#��J/bj�B1Ad�t����x<���cŪU���%%B������Ҕ�2�W8U�@3�
g��,W��jl�z����T^R��f޺u��œ~�Ӻn�����*o��կ�>�㼮��Ki��}������o��Ȕϟ?߶��a%&Q�r�V�(�UƯ�c�*�PL2|�j���M�fӌX{&��*�j���
�I�s
��
��Y�zc�f���n�}�nfB�����s���vO�qׯ�Ώ�!\�E��a�f&[�DY��u�,⢅�\��t�����#<���%q%D8��#ܣ�l*����)2ETX�[1��D�+��8��:+��Y���HI���If���0aTu߶�VېD���'�����&�UEH1��Q�ĕ�%���^Yc�H@T�\���9����ޘ���w�w��$HҦ}�ڬ�U�֙m��͚�p���T��l�X���y�� IDAT������Zb���Π���,V�L��j��BE��Z��~_����g��T�1��|fo�Vy���[3a���3;��1�����z�Z&�c|z���\W��Ec�"�1y��P�Xw%B��Q�Uƒ�MG`a�,mˊ,���Vj�]���.o�q�֑����g����U���DA���p���|.�����O٤�yW3`�����u������S*+���8ϋ�HT�T����=�|�6!��#`U��E��~���9�m�_��ڞ�Lu�y���Q�ʫ02�:����~��He�IF.)Mk�L��5�S[`z�Ė���z�V%�	�������Q�$+D�,A�s���D#�1"#U�����wi�WD�7�Ȍ<�ӝ�����<~����x���-<��:��r��։�Td�r]\��f1P�I(����9�5��8�sE���4rQ1o}����U��� &�6�Ȅ$b�=bR�q� ɠy|P��w���h�#�������8h�ϭIkbTu�9#��jD�GT
VH08�T�9�**� ��ƙ1}���E�*���'�ɦڒ�VY%<��_�
}{���$"���r�5e�zY�#C@���l%^�8cx�y]M����^'��wf#VbfB��D�g:Kr�I��d�(��ڽAPD���y��z��I��|6�
��ڈ�r�=*�1��I�x>�y4�Jij��<�	��qтD(�E�͢JU�f��"b0����C�M�{�Ͽ<L�7%N������դ{T���0�Ql��̢ܛH�0`�B�D������~��
�;#b�N��>LUi���ၪ�
��U�D�,{�\��M�ڬUD�l
E��k)�1�i�;�##�L��5�{'L�c��0����+E�1@��=�#]d�����=��n�����@"��}᩠k$��t�{~4�i)
�53W�~�WU��<�'��mg�b-bI���"	R���A��5B�s��N9���HZ��u"a�u�D`��J�ܪ�Dyͳ%+cm��x�����y�k�&tۛ�03Ed!|^���@�/�T�Vai%S�_��^TT<Q�:���q�_�f���`e�q�I��*/ʕ(Q{���缮1�W���H�PPDL��˅ij���l'��$�G2�=�v��D j*BsҶ5�9|���m�����e���[c��7^�7P\�32���4 ����NV��s�����F]�x�,u�v�,�D�LXX���M�|���7طM�#��֩��猜�w�q�o��ǹm��32s#��m��y�߻�_��_^?����YJT^G�fjb�~]c���4(��D��&hT�q!+<��pUe$Ι1���*�j�F�YU���vQ՘fZLYi�ED	�!������ �¶[��?B6d�1GEh3�#�9ì���^ӳr]�q�$n���2��R���b�F�քd�QR��������"�R�DĜ\h-��;q)D��8ٓ���u�3Gf5BA�AfQH��~eTU1+�ۊog����,����V��Rf1T$ f�墘c
��D�����s��u�m{���O,r��Ɣx`��5�HLP����/����~�������,�����3���Y�UL�j��{��D�ph�7j��H.ֺm��>��"�9��Ă���	3�R�R!�k$e��@&G*�y����?_�2��w�,gʢF�k��u�#���(�c�\Lm}!���f�!�n���<33�.�L�v#&j�Y�5�@US�M���k�ϟ?��zfΑ1�Z�Θ�ETpz��D�,�t��p$����H�\Vv`!@T�V^�
�#X�羑ȧ"x�B�h�|EDTL��d�H:=��Δ�{�z&<F�ڶe�aMT$��f��~��ϟ�lc������DT%
��3̙�cD"��t˝�J2K��*�R[�IQkbf̬��caY�����m��9�� �?�㢌~37D���t���������c����i��x����X-���E����B�Xa�%�J�#M��V2���JI�/���-�3���Db֤�bS��ۺ���{U�* �s3��5�U9�(o�
s����P��bBo�
g��T�1fE�K���#K�
U�U�aM�#s��U�BD"��Ȫ�m�E��&F{���1'@jZ�9\۾��0��U�5������}L�z��1���E@�#j}o!uE&e.�꺮 Bf��VqMM�fb�kx�YT>��)��X�<=��KG
-x~�LfU����q�
>�`��/a������q�BN�d���z�q��r�uU'�DR,"���2��(�Y�6b!�DxbQT�9�V�Y+K�3	32�H�P����6G4���������9��k��D�qE����P���fF�d�0E�D$ �Z��aAr&ZMI�[�7��Z�'��u]sN&*OZ!��5�$2�ʘ�y�kΙ5�7�c�1�HD.�����;2�v��~|�6}��=|��+-�@�ʜ9�,-2�UBU�~��p
�1��M�w��wQb��3h�Hʶ�sLg�.b&�,�}x��㝠��� �� �����N��[D=�q<�:�7N� �mf�*k��?�s &�%x[�b��9F��x+�b5���q�z�P�I��BP�(SUD�^��*�5�QL�T�H��繚���Y.��0_���H�F��j,r�1�+��K����Pf���*��cYklԗQrݨ��*�Y�
VV�kĜU5}�1笘�IL��[f��y~����&��x���u߲�q~\�,d�b��a�k�
��w�d�C�Ru�̞k�ʔ%�m���v����1�I�x>��M�1f�V�H���J?`�]�3�5N��x��w2�%���Ƿ�q���V����DI�yRxV��?#K
L�MEMI������5�Zgb!
�+|J�+;ϑP�39�	1!�$�ED�9<�
��O�A��ƨ�/�y
�%�Ԙ��"k��`��7��L�TL��P�kĸ�XUzkF%��R}�"�����y�gD`�A�n#L�)#&��q*3����Q�eL�XƜuzƬ�k$�����~O��V5Y��@x���������(�/,h �"�	)��d��R�s�����[������̳����1��93�o��Ҍ�J���bwUU^d,d
Wŷ(Pi�x���||}�Ϗ?�b=��	�H����%a_@ȵW��$�&��ۭ�}%K[�ބ4#<§��m�}�+y|<���6<����T@������w��u<E�YƜk�_3�*����d�=��Y0�*��f���z��s��q�p�M̶"n��1����i^��\�DSef�$�*��/�Wqf������\���#�|8@LA@�[�Ƙ�?����9~��_~����[�׼DTD<"����������edE�j���4�m�}n�==�q|<�kTUD��&e�2*SԈ�gd���0�K�1���F!��v�_�>�|��=�+���~\��ʜBT�8�u��5�$hk"f,&̢j;�.mH}֘U�����~�����9W$1�I�℀Ԕ�6�IC�y~�x|}���Zgٶ�VΑ(ePDTѾ�Ltm���K̷}�b⬈�#K�*�m�P&(G�P�͝�71�F��"�w�3����2gF(z/Њ6���c )ˁD�WE��3Q�~}���qxDE͙_�=�bk�5�t����y����B�.F!Q��0�b���#T&	+��Xߪ�Y1�Yh����He�q�����u�/?-3��u@4@���M��_N�_���q�߾�K��m�k^ǙIk���\@N��dHW�*�$�����Lepe���E �Ws�fLD�6b3�%I�o�R�(-��$	s���"��Zo�n}�nDx����K�M^X��s�',<�kαjgQX^&�D�N�3N!���(
P1���3�X(�!��P�U��>��T�Ғ_�̈9�9��##���Ff��x�O_:q#�+�1e�ȫ`���)�B2;9��DUL%L�i̽o�?*���"X3VVV��m��IL�3ƭ�n����Q3:��}����{E����:����SKa�x�	&��"#������XD�zSU*�J. 3�5L{�f��(Ѧz�3D�gU9�#d�o�gJ:�@�-���v�eT�s�kz�����OwNT�y?�3Dؒr�uR����"�d��1�<�J�!j��{^{dF�.��� N��{f���S��_R�1+����c5Ϟ�c�C���O�q6�h��rfF�يe�B���x4(�1������]��'n��e����q�W��N�R�t�}�ۭ���Z�{ND��H��_��w�z�����1A������k�/?�?��o��~��|^�+ݝ�(��#˩e�aS�uR���Z33�CUY�K����ݯѬ1%h
p����"f��i{��b�m�߉P�	���,��4L�P1�s�nEQ!��<���Y��Ӈ3��Ӂ"%��)2�#���v�̪�(LE�
{����0�k�9���5ǘ~-�< ���
��q�5�`�gU*Ӆ%��v����u��`b邗ݕ
�U`��c��@�jTԚ������T�q$3�4eS��8 �Ǽ��O����G�yQE{�}o��$�����?�!�=��YQsF~{<���=��+���[���Ŕ��� *&1y0V,�H2K��XUa�5T@�N����>��lW�U�
��d���~��rM�U�AeT	SeP>O��O�g�Us�*U����nܧ�r*˺ի,��n���1�_c�K "Y`&�s��V�B��gE�*��J�E遗_s����yGV]וnf*�\�<�g�Z���˯����c�3���A���g�
�h*�$��y��}�T��	�pB�ֺ�O�faNkm��I�u�9/UY��,�p��y�1��9b^U�R��'W���÷���J�{��zS�C䴲zk[k/�,����!TD��3�Yb�B"RT����""�S��WXdD�u}%$��*�3c5^*��� ��,�q��p
��\���TP��h���z�.E�(/�U����֔��bN��,K�'"�uU1aY�����Z��E= ���_}�n�_�����x�|<��1�G�c�,V�0�m�P�׏Zom[�$%1�M�r�sie2JE�q1A[�L?ݶ�y:W}�����h�QF����g��Nw�3�\��$2}�t
R��9ψ��_i�2.�������8��?�5�[���������&�d�AUˢ�`j�e��ԕ��k*�
&wU�������u�qle�*_-f�^�m��(jf��^@y�������X`����;1��3P�,J��=Y���*�@��*�hזY(^��|ٵ^_9�z�u0V�#��R%aQD��$Tb��=�h�������Ȣ�day��EN>�'���9�+���Y���۞Y�"���J�+,moo��۶���'��O�?iۈ�����M�L�[���Q�<�SUz�S��U��$�m�>�3�~�qKNm������y��u�90�C8��qe��dZـ�5r�pe1$"�X��� �,^��܈���
D������,R�b>̀�}E
Q�l��_U�̢Vq	C�� QM_N�c�Y^��*`�"��X��1F���}��n�M�Yc]%��u�Ng���Fd5�">�k��G:�D���/����Q����ua^�U#[�	b�{&e&��=
�_~�
(T����Θ���@f���OoH�o��UU{�X��;K[z�\ TU�J�e-�ں���NQ�"��K��1+|^�(Ex�)�۾_$���9��]ÿ�`����oߦ����}�'��JE̙����B��H����1@Yj"b����؈@%UTEJ��I��W�2+���#�UM���sf�8�,��0�Eko���S��u;_X�jƸ��ӧ�m����1�bPe�T5Qkxe�q��=���.�rf�*=*�Q��>��|����m���lۖ�f�Yѣ`�X#�W�#|������zx�|
׈�mEc���ͬ������Zo������4Q��:	�֬u᷷�69��x<�r�Z�d��sN��[�3<���Fđu��||T�*e��O�XD����_���?��Mr_s�B&(�@��&�$����c�����~.ʀ	q�J�J��J&&��s��p,�
� HF�$q�L�:�j�?1��㺎9!�B
c�*f݄��9s�Z����ʚ��֬�{;�WC2Xo�_������<�%ExEU���]��KD*Ɗ��q�/�>�0kz��y�>Ff�|��$S�a_��� "Q�j��)��Cи��tB��~�o۞�����˧ۯ��χ��|�Hc}{�ҷϭ������B2T(�n��_~j9��=�)\��4�ē����0�D��P�r{:�?��q^����B;�������o�q7B���Ut���e�}_�1�q��]2#BUb���Z1/Z���Т�EU�9U�0_ሥWY����0&�E�jӫ*P�s�,�s�l��J^��&DD
E�Dx>�sD�3�#sTI�T5Τ?ED�-e�u[�I���"����<��1��z?�U�s^��e�#��*Pan
�<)ց�"��HUA�+�=��C"�QMu�����o&�*��.f�/_��mQU%( A*�H(�d�RQ��N������s���u���Bk����P0�!2FĕW��q>~��_ގ�k�wb�������7��,�������3�ڻ�<χ���m��7Z��NA��.*�������ӯ�QD .*�9�J����Hյ��� f��"���p�Li��z�Y��n]W�!��������288@&V�q��Mj*Z��Ϙ^�w!C�M�u]�R�֥��o�9�s]z���㒇dqf�iI�m$�(f��D�=��I+=�>|&�X�H����f[W�����m�`�J������IB!�*T�L۶	�Ŵ�إI���s �L�o��e�d�B����~���_�CZ�J������������2�
�g(�ң���C��Og*�:�8#k�Xs7�&��w�=�I2Q�)Te�>���	���_�g�*�B1�=��QIQ��>��9��� �
�����*�<gd�媒�ˊJ���{���8KҴm���Ľ7&�����YT	qk�i�yeͨ�"�$��Y��m����1��:/&^��%8`$ʔ�:�8D�����a�A$@�W�l��Uo��~�5+�P��d��m߶~����Q̕�T��bU�.~��0b�v.RqSUc�8�Wkr�Ҿ_nj�sΏ����w������0�x��y~j����ND��Y*�m���p��+�Pf-�22+����{���%BQ3����&��o<���F�8 �\j+��Z��E Ϙ��JUef�w]��s
�5��D��dxz��qfrƼ�(Jt��_E��}���1#߅[�*k���Ә���������7r^R���9ָf9p�HT��V�F�G=8/_����H�~x�D���ɯ�|j�Ց��Dl��#�����%�Q�|a뿝��F�\׸�S��d����Ԙ<G�4U���
>�F̖A�Z\�g��xֿ&+�7�'�����ۿ�/��K�I��8ݝ�JHhVT������y�dQʈ�~΁�m�mj
�E5#���d�bqqy��*�	�6h\��QT�q�_2�F������"BT�WU1CD2�H$ң*��S1/nt�X��bAyD���H@�����ܲ(�{�x$"YH�k+�{�\�Ӊ�_�T}M�+=��gU�01��T����8�\�*i�D�*75�~�r��5s�(�6c��Pm�5�,>�93b��TI���NF	SŊD—��YHԲt�I�lL縦��k���߳������oo�T%���
[����2/�`3p�GSMU	j�U*b/0H��ܧ���K��0���-̈́�bdz�0�5�U�D IDAT�s�c�LOp�׏u�(�����$�"�jz���s���_;b%�-	9c�1�y�1�1��,D$�5�#�FF]�u�sN~||��K̹��IT/._exe�="(�֞����j&�Q?䚋�b�
 -���EDU�����1+I�T��@U@��5U^Y��y�`fD$�U�8N�K�q�sx�L��������q�?�ʚ�������7o
������n֙8s.B��_;Sa�n�Z�yq�*�k�c�t�u�]~�4����!�����DTe�����tW =P�Y�U�gd ��Xd]-H�GULf3�H�9Wa�$��U)��U�[�(r��X-�bFVt!�F�k�uFD)ʧ_c^cĸ����y��|�qo�cIr��}�����Tqmv�lj�hZ� @�����FM4�Y\�X{f�v�qw�oӅ�$���Y]��m�dF�o������LS-�N�	�n���` 
 ��������������<O�/n��|>��J�\'���u-L�r(�f�H!bK`D$L*3RF�Y���o۶��4ՙ����궯�������> �����7����_�,�?gXM{���_������?�)u��ݼ�M��j�@� B4sL*�D��{vaDBf�4�OC�4����=t7"40�T�75���BHi
��TH��m�H�9O��X�A��b����2��%"1���N��"�3���TT���P�"���X��3 a.��2^��NԈr��Pj$!�ka�~U�(!BeXr&D�kƀ�ԂnMa��2G��2a��3��r�755��X$�H"�l�ĉ������!�\%\#�3��X�T�H�f�";׌��$S�ܛ��9��������/�����*DB,$�2y��0���_��"2!�+"��;xP���Fĥ�A�1�!��ƀm oD��_�'x($DBs���>��F$4W�)C\X��#<���gF������1��2|lqAdb�E���x'�@x��h����wS�OJ�U�q��뺩��d&�޺�����U�	D�bw}�7�����b�U�����I�Zx�nf�c�p�3�z@e�T����B9�d�w��c�C���)3Um���:%55L��Ixx�ڧ_���E��O���K�W�����[�`*5	9���
O^"M�}��Q�#P.�n�[G��`!�*Hy�w$�{�'`BA���V�C!�(����q�"bz`
 ���9ש�j�/���!=2���r-#S��?�!F~�%D�Zoµ2'P#@��强[&%b7��Á�� �<O�Bd�;\��FK3 � �Q�!	12"�"(LO3K31;���\\j)�� U.�t�x���mg���Z�-���E ��"Ӊ��=P3"<R��[��p)r�[���<(�l����顝/�?�� }{��oN���	����H�h�ȑn�'��
�0B�,3���<�2.�,2az7SÌ�H���ИkD5�}o�t(��8��M��Yj@ӑ>�P�m�nѴ7�2n�Œ��0ڷ�<�Ȝ��,�>�=�1 00F\�$��E�N�V�3#\=l۶DD�ޛ��ty�Z�y�������L�<�r�2�w*L����ƀ�f���e<׏��gD �4�'����r�_�������+6Z�t3�=F�lPgOڞ7��gz�Hh�{����T8"�GO@����[o�j���ڿ������'_<�ǟKA�k����ȃ�~��32�sp��&p����{7�H���֞^I<�k�еĺ�9Q����¨��,��wU*%S��[t������		�t�;!"B�J�����d�KBf3k��.j;`q$�Gw�{_u3*��"����O�SDPPJE�dfU���"�D�8"�VI�A�3�Q'L������!��(�P�G2�/^�~Y����90�
I�����Hx8Tij��)@ " !"Z,�41�%PΗs73�D�;%���鋯�_=���ھ��_�?8Pw�B������	��!#�Gh}($\�u����7�$�����;Dw�X�̠@hZ�;0�aq
�R<�̅�2/"%/'Su���	(��b�w4F&��mU3�B�I�}�������R8�2O!�Dk��z���v>�ՔK�������o�(2	xlL@"y� �h�DD���c����5�轧 sqA+��kS ������~z>'�e}�k
)u&��|s{2���M(0�O�o_z��|ۚk�M�@���[��������/,ȼ��_~��O���s�f�AqPhP7�HW��i��<"��U@ޣoC��I�x������$��j	���QD���"B#�pk�Oe&.�Y�d���r�d�p��m�6��Z�x�Ʉ�47���!�$�	U���!G@�Œ(EJ�mlO
�(D�g���2s۶k���u_��-ں�@4���@"dM�j��M-�ݝ	�S�F��ӈx<�d�2�FddoLP'�����tz:=>E���O�k23r!�B��tN���$�&"pQ���7����|�Η�E��)���������{o�����ˮ�n_��?�p�yj��-Y�sP�0P���M20cLM<�C-¯����#��������{�U�
3�ܪH����C��$�0	e���)!#b��sI&��^����r�a���&B"�‰@��\������nl��Xs�cB�i�k33C�ZeԪ"��=�Ɣ����k�e�PD�L@mı��@	��4LL��/�]��&�/o�㋃0�R�,s嶇`s#�I�������{k��	���DP�ҁOO�};m�ɬeXx``����7�_���/~�k�ֿ�`}��w��ջ��O�9� "��13 _�Jȡ!�")93"�i$�ٮ���0�4U�@ȼZG23F�0#9��0frz��[d�k�Ӽ,Kf0�DܢCBX�������M�0�h�(��ã���؃�x�g�"H�,��c 73�L
��WO��#���ٮ�@���=2�d=����æL@�a2�T�̈�T������05#R}Ȉ��s�W���;i�7��q:��~7S�2 ��	�	е!IF�jg&L5��u
;]X,�ytH`ψ�R�>����Oo���3W,H����g���9�*�T�2���*�b�����$S�+1!d�K)���WW0s1S������#X��#����J7
NTČ��V�^��R*�"��B�<M˸}0�<�%��:��{b&�3�KF*""2v�j�E��N	��Z�m�}W̬ۙ�ޚ�G��̯}C"����ª��>1�2~ND�	"!�}���^s��ߧ�2���9�Ȳ�����?��p��J-wǻ���R�Zy�!io��V)ĕG�̝��d�*u�{۶F��7���U5��9}�x��/?����?����} ��ӯ����/~����B�;�۷��BH�`�e�T[�@�>�%a1LU��H�̥3����fY�x�A��",��K-B�aͼL
aT����/fj��ur�.&BbD(���TA~+��0!Xo�AT�[�mЋt�[�;��jF�D�t(<C.�e�ɇÁE"�t9'@���p��r�P3)��y��YF��9��!"�2~���Wu�I���Á�d�պkJ�����:��	j�D�V@$&M��x�u�ý�nM/���K�Gl���û��`�}���_��_~����o+�
�@j��Cd�v��5 �ˠ
3aG��̬��"�&b ��"�i��M�&�tX�h�=���ל�q���)RJ�)����L�L���'�����%�A2S���fr�pF2&b&p�=Ѐ��3!���wo�" �MUGz�},�0Ղt\��y��C���/_�-˴�}�-�����y+��\�ه�iwĄ�L�p&qψ�R���r��x�;
J�LA D�BKP��͆Jj7w@��2.P$P�Y��nnnH��a���{o��;��H0�k��E����g�~���7ZX��=>���O��#�t�L��B”є�3#3dl�hztd&Z�ʰ����*\(lj��F	��<�Ñ���j���Ԗ�2`WsS��5�" �4G6̀$J\�CN�֓�� �L�0���cԝqmO���Wf�$1��M#�,z_����oۖ�,��"SfD#	�Z�&*��� �w��/�==��OM��p�d�f�[.B"2���I���@�����z��L�r�E�JB8�A&W�"b�R���
TOϧ�������G���v���Hdj����z{sn_}�����o�IkO�����/��Z�ybL�187w�9vO3�F`�p�c5�Hh��(��Le��p����9"��{o���0����ױ�=�M���_R�P�o�DRd��PdfI5��|ٞ�c�u9&0I�:Y�vݷ��aM�y_����a�RK���C���r<N�"R#����$`����T�^�9ҵ�4f��)#ZD469�eF�*����>���2M�≈<�{���_Ƹ?�H�$�n�8�l��s�� X��j�ޛ��9�!�f�������ջ�����O%���W,���O~������pS�<M\*	���H��p
f��(L����U�m����2#e�̼,Kx�u;'H-n���H�U$=�}����p�=��Ừe���]w�RX����a����Lf��� �Ōx��I$�#B�᭫FXx�S�!G���VF(T2�8�
"�z�(�@�i� ӻ��		LR��������B��M=K)IL\"L��� �Y�NJa����#2J��m{k��(R�R�D
�"g�����`�@�Hwk�[�]u���Zz������~�/�����t���Yf���	5\d���x'EL�D�kړ3�g
�8��@�N�]<���qb� ���+���"�\Ě�@Oa����*�`�Zk�i*��˃e#��ɂ����;w��77ߴ�ʜNK9��}���m��_	HfD,�h�BZ�i
R߶�w�����։F?� �]Yw�����L��7�Ln�~�ZD���2�H9,�<Mۮ#6B,5	�53c��2{W���"}�L)���(�yc�Ll=j��{�4�p�m�Vm_}��^.����؟�/P��_���"DL	��Vf�yZX$��-$麹3r��Rq��C	�H��Q9Rc����zcL(�LWc*$��uoCόI��T��!k��ڞ��V'4��\��i�1!��$��ɑ	��tWW��v�.�}���i�/�z�V�����ҷK%`�R*aEb���L�P)2~憜�4!U�}��u�����4Ԉ��kv����áLeN��Z[8�/K��91D0��Y��}����������vn��t~||>���ݶs�&�jf�����(�j�R�f�n{k[�|���_�V���/,���}����N��T�1��|L��F�5m�p�
�$,S����9�N�U��4,��="�92�w����i�&��I�e����z�P�j��ᒞ,L8�ZL4�RDD�SD�Q՘% 30�} 5���/kkm�]MUu`rL
"s;??8�2f�3Dq�p�4��X��x�g�Do=3��Ǚ.%O���qݚG*�0��2M�a�o�����b���+�D�����ps8Z��es� y�lۺ>������b�����y����7p)<K�aQ�m7��L�<-�۹Y���E����e������Ǘ?��O�L�8�ܐ�ijf��f�	9���1�ʙ(��p:�Q�!���,�J�Re�B�k6��e�.>h#�,u�B��3��*d���gh�R)�NS�b�cPI<e�����y�o�o�漢	��f�.8��kdL�N�K����4�S��z�!:dB�]ۦ���hZ�2�U�}�,�>a��勗ǻ�����Ջ�7u��Z�y����Ӣ�[���/����n���kx�p������L�<�T����U�
YX�JQ����r���鳏>���ﵰ��v����o���L�`f��[xwU3WU�@H�fn�I\����VaD&&$NK��w!�R�a�Ă�5�p ���6daJ�ZEDXj)\�B�P)=M�x�t�L@��Z�X( %@B�������f�Z�[�}�9.�a��@��=3Y�KbSǰZJ��	YT���γp���'	n{��	�U�S��%<!R��N#�tP7�p�pZ��x��ts�y��մ��=�ݛ�������|:���{�9�'X�����8"��²7��{� ��L"O��e�ΗK�wo��^Ͽ��o�_
�l��-@ƾ>�����2W�b���ul�&F�Y�qmQ�G���rMC!�T�4uD���BJ�1{ŹP@�����0$�R����$ &�P�͵��@�D��zo��rk�t�Ld�l`��[���=��[k�+�0/����2k���j-\ƭl�&ba@l�ᙐ8��ֻ��!e@>>>�<ߌ���i 3��,T��R�BM�*�V)�2����0�]��?<?^N$ؚ�}����A{G���5�ڶA�T+�f��Z*�z5�z�c;����ԾZ����}�:^��3�{������������|x{@�L�X���"�Y��L�3�dd"DF��p�#��G�gШ�3Rz`�bA�N(�Q�i_�W=d^�I�z�"&�Hw7BpwOO%�ӣ�ZFzt���z2m�]����r�"a$"�:bt�EWK��x�Te܊�I��k���{��id��G�晨`$��2E����QP�;	f��4`)�{W&���I{�n��}[���9,s�(�PJ8X�C�n�-"��w���Ln������O�~��i��U�-�Xcm�������xy'�ԂE��]�mDdD�h��[&b��"��p���*A�k�25$�<��<+YJ)�Ȝ�0J�	RKB�����q-ӈ�%
VF�Lս��n����׳�ֽuM�]�ޚ�9"��G@o=<� �Y�E�T���˻WSY�L��2-@R�m�ߋz���k�OE��(�
aI�R�0�i*ӄ��2��\J���3ˌ�q~ywsws[�R7D"e2�����OOO��O��s�����������X���n���,$Eus�0���~��W��_��o8�K�XW�ߧ����O��/~��6%B�h"����Vs7���k�D�cK���#}+(�H���T�
	,C<F	�^.LD��s-�<4�"�>��lf��B�Ũ)��/BƚI��2&mf����zn�`)"�Etu���̫
���s�Ł�2���y-��mJդˮ��M]{��Zx�4k����BE(�����ۥQMh��	Q�`���]<�����K��=�9<n����ǧ��cWu�2��l(F&���yfL���!<݆M��k��j�?>�ߜ��?�t{x��m.W�ra@�����?�?����խA ��JHRJ��b�} 	0�q��A=� J�i("�.�WD�n��(�ʠ졄�³o�9�a��*ٷ� ���r�#����A\�#?�n�EPZxn�~U>G8��H��hZ�������Nk��ޭ86�����k���m�y���}*���j��<�E��LMu���֝�Q�K ��nͽ����oO��7s3�pE��Yzzdb��x#w7��O�[��E{�~q,��>���/���Y��\U�~ae������~���?�����}��B�	��W�*Q�wU���Y��u�4HG	�T�iA]=z���,B\���0#RX�L�Sd��tC�
3���{$'ZF�_����A�",H�D�1��H	"�̭iF�/_�:ۨ�9�*�� D�Ǜ�L9�f�g&`�U|�]9 IDAT���p���`ۺ==��i"b/ra|>���YLȀ.�P��PF)\E��c���=�O���֚ZCDs;�FB�����(L��Nǵ�D���L8�j�����Oo��J������w���wy�f�Zoo�Ub	qWI@E����Z��f�	��9*QA��$up�c<���&�ؓ�"�2��FD��f�X�8�s��x�i�o]	���1�Lf*��Ⱥn��s�+AW�L�����`B������\�k�r��2z��ޞ��*R�ʧ�������ҕ �1c�i�����"� �y�\�«�a��NId��k{x>?�׶�۶^w����3=<F�:S)3*cg^/���E�V�f2���o��xs���>~��g�_C��XX�ۺn��^ �J*m�`e��5`@��Wk����6K��%H�@& �tbdD ��X�P���\��2���)\�M!rf$�{��y8X�EH��@I�:�:M���w�抌�0��� ",E��+�S�8�e���R��e�t{:=Gئ���1�"�����SP��a$Ef/��T�*����֭��N����ۛ[�n==�{���k�aİ�"�	�9�2���ށ�2��v:8"�,<MM���r�~��߾����z��~+|C�w�}�����?||��|�W�Y�3ǹH(�잙��F:Dr�XM�(���L�œ����@Rj$d	�6,EID�@���j�~�ց�&��H05C��L��-a�3r4-G�b���b�a*�SSk��s�e��L-�`*d��\k�����������H%���d
$���H�݇�'��A]���wc�\�+p�\��:,�t������v���LpH`J���3K�	�@uZJOcL���������޼{�Ϭw����?�����o���?�ްaU�6\�@E��� S�����)(�|>�H�H&NwMD��$)uZ2ӻ��<O���P�C%P�ko1NS!VAh�"6�D��b�Lt�k���a"!�*�_�Ƨ��˷��)"��T�X�x���憘[s��4�y���x�n,����o��}�mU��0BN��I��H��2�a]M�D�!���pS暔��CGA������1��c�G�"�7�1}����͡�zs�	�|�<����~������_����:d�wYXn����^��O~tw��=��8iWm}�F�44#����8��&2��"�J�L��N��9�R�P�JM@�H`�a(��˶O�x�c��:f-@����� ��1�����FR�\G�Nʥ{&<,�˻�����W\�!b���f�x	30�M&��zywj���>r�
��h�SBd23�f��)՜#�����Јed����j��=2�|�0�q8� 3!,9h\�=3Q���M�\��{_[�n���o޼{���w�������>�Ǐ��t~����H��P��z�`"��6G�6"	��L3S�z���s�{)�<����y�ɱ�a�U���[ۻw��Rʼ&Y�����M#��i�="Pjs�
V�2�M)�����;�}��%���"r��7S톑�,ű>=<��4���YJ�D��x`#\�,���j�j����~�� �#/��P2��t7U�{77ww��?	"2`�K2�	p.���F���΀Hضnۥ?��/�~�꓏������O�}{����I���8ž6������E��)�r�=�LIKq@�qy.�$nyU0@�9���LR�FB�B�{/u�ur"��.����i�d@}H��4\=`�������l���̷��x�����.���rf�z9�������[7c�@�����nW�/�0( �;l[��HaD���kU��^���ի:�H�H�����~Y׳�S���Ջ��R�i��z���i�P
F��r�?{��ӏ>�<<�)��o2���ֳ�L*/_�(��{�9���i�$���j5�!�K���M��D`�f	,B��zc���V�L&/1o�h���DD"#(�����iNDbdW�0"t��v�=�#{��}�N�����2���i���5����$n�w�T�p����B�d�趭�6�_"<��{k��"��"g���9@
���|�u=�N@���n{dQ)2�Vj>*�1hL������q�}��DЁ�[\�uk����Ǐ���W_~�!�����[�PP-�r3���Ȅ �
2�)d�%|��F���j��*2"��,���B��:LKR�V��d"s߷�#��X�X�`Dba���{�ޑƿ�"�mc�Z�M۾ﭛ9a0�H�$N���|Y��ߛ�i���H&�D��ә	��[��۹놐,<ȏD�n�#0KD�00|8*'����{�������
GPµ��֬�Xd��p�'*�a!H�n��?�p9�`�mf�u��o?~�����W����V�m���t�S��ò�/�^�uJHb����P
DV5WMB]��v75b��"�Z�Q̺�1�i�s�F3�<j��́3a��3�:�Z�̴�n���C5 ����z{��#�*4�B,�~z8=ܿѶB� 3!$�����w/���ܞ���msk"�Lf~=�y�=3��"�����M��/_��\�F��+����Px��)f�_��G?L.�y%�W��?��j����|ٶ]/�������w�����Y��ޭ(���ĥ"`tU7Q�k��v ��PG�S�ps����2�~EF��+� �f8
UY\���  �1Tu���i�R�4/�iZnJ=�����ͼ̕��CJA�u�|[	z���LR���ֶ�]c��~����}���|H�q=�Z5C��sؗ�1~�Lx��?���q�>�1�GX"32x)t{s���e��x�y�!̇�5W;,��_��p@.��i��?<�����/�S�w8������t}ںg!�m�}'�I� �)`�%3�H@�HaH�ݣEZ&Z�#q�G��Rƛ����6@@O!@p�p�t�p�9n�D	����"E� #K���D�b��<�Ԥ�d)E�Z�_�,Ǜe����W�4�纭��%�@e�B��O���n$�mW�	n��#����׉� ���d6#������'�������@ܚ��ʹ�a�Y�V����%hY/-�K=�noo�馉\"�=����k{���������������𶭗��w/g߻G9�p��"��r�5C&���W"�"	#���^j��T���3!	D*���v�b��f.���w2sb��Dw0$&*��:f�j�P����z9o�T�p%�@D��޷�Frd�K\2��dK;k�00����0�#�4��dU^"��!�Y��.�Iӭ��D�����Lj'��T2s�T�c�n�!8��B�L�dro�����u�ÿ��o�B�dj>�|�B�U��
`�jA*5���uz����{:��ܜ�>-O��mY�����<���:~-T�Z�z�n���?}{��ͥ�}��piW$d�љ!%5�N懘^�4�b��n>g�\󑆪�$)?dJ10�k��9��bjz�2�ju	����ͬ��k�m�Z��	�×Zt������y���h����	����1g&f����5��W_��@����ߑ�c8�u����)�\�Ԃ�禸��3�|�u:�M�����}[�����޾U�5�ի�e��~Y M�)3�pa��du�k3�aH�3z������sK{�"�L9��y��i���!�k.�H���H	w
3fʵ�D.����32Ô�v���c�1Ɗ �S=�*��[k!":ć�6]d��ж�m���>�TApN�1��=��Pb&�W�V�#ŗ 1eL����4�:����#�Ǿ��'��r�32[uغ=~|L}{�Ý���>^�?���{Q���Z�����/?���_� �ڶ/K���r)�����4<��ގ�	�0�2c�Ah���x�E�>�G�" q ��8�.j)1'���FD�K)̄D!6�5�H)g ��u�O�Mho"����]EO�֒��	�5���CFF,̉�)�\��#�@$Ĝ��8OS�%1�y�9�1lJ%���>����]�t��bv0m�ԻypYv�6y��>_!�&��_����~��_�
�m���t
ꌔR2�19�|C�B=ܷ}�{S�`��3X�\U�铉�;��G"����9u��o]'�����9�|(="sN�ԒrJ)�Tz��@
$74@��sD��^^��vs��#�r:��f�hM�&�oD�G�kNy��!�8�ĉ�~6EL�)%b�)��ĉ��s-)��)�jfΔ!0��ֺ��u�{,׶�{x�̀j/�dս�/ח����o�������U�o�&��۶zʩ�Χ�1t�U�0�DD�lbch�3+��s
$I��ܥ�CFPuMD�	���1(Q
 �`"�˔�r�)3q�R31������1L��1L1Q ���E�l�o7GDJF���"D{ﻃ��!:�#����`�s��<W@&"M�@@<]��) 
g�h�S&5�۸���?>}x�]_T�m����*ۮcm��O������&��?����Wn����i���Rr���`fa�D��.cGL����vD_�L0|ʳ���L�)���"23���2�{P�Z��s	.���9�Z�S.S�Ή���;F3~��*�h]��z�[[o�� 1r��&7���Z�!Ce��zxx0ұ�9'"J)�᫽;3���j�xwNw��e�h�e]�[�-�}���t���Sb��F��/˲~z~y����Ǐ��C��XǺ����7:l$�ZQ��8�P;y���0er7�<<�!8 8�!�ba���@��.g�H%s�)�
N�<�4���;��Ý7���8�˲����G� !;n[����۾\����qLjќ� ��~�Eꭋ�sJ��K.�䜋#�!
�i�[3im���r@
�4͜r.�-<LԺ�������v�����m�u`���ӧ�eSs�������i*%3�c$A�e:ͧP�idNbbn�XUì�����D(&L�s)GO�S��<M�<�8g�!�E,B�" ��8ժ}�[[��D�&[��>�1 P��>T@�$��������(�L��a҇��>�Lq�J�Ճԣ��u���_S��P(&���d��T�ֵw������w�~��~��/į�����H�����'�R��r�#�źK9O��(��R��S.�d���sws�c@4�57�2�_��82�j��Q.�t��?�z"@w1B>LJr�G������n�������$ʌ��2�\j��M���U�D��
rJ�<��KI�S��T��B�#ZF���j)�yYWppԑINs9�f"
��|���Yo����k�h�o�~]�?>��_����F�͗�W*��u��T��\.��`s3�1�)�� pUpC��Q����5�k`�Ĕs��0q�."���xt�Dĩ a ��ۺ�m7Q�רwG��x��\�TJ�
�b�m(���p�%>����,�2��:ה՜/�K�N�K%�T��TS>]�4M�L4�֙/����r��xNx>O�ib�<ͻ[ �[���e]_n�޾�~|�_���E���rݚ&�)s� ��懅�"1��H���s����t^�k�#�Kbpp� �m߻>T�EE�����B,Sr��������R���~�."��4M�s��
����t��Ӝs��9���]�3O�a��+�Q�Rj�T�S�Of�8AνuPI�R��̓z
B���6bۺ�!�֟�������o_>|���ꗡ&�-=��ۧ��/������<|sW�T	��FI)�K�yk>�r�1!�s��j��AD�L���l�
��H����`�2!�S�y�����~�����B`�,j��S!"���5g�u�m�Ϸ�1ϵ�gb�ӑ�>��SxJ9#�Tj��1��|�.Е��C�مT�5T4Wt���e�>Bw-�|���,�#|�r��?~z��]_ֿWS��X��ѷ�<��|z^�&��
��>F�WMZ7��r9�TD]�͕��-������ �OuB�@:��S)sqt?�t@(�����
��#�^���s��.����H���99q�bf�)!&�vpd�թ�����ui��}s@l]�!L�B�a���>�[�����{
w�xYn/���y}��_�����XǶ(�ݖ���.������g�!&@�A,�ۑ�h���39�H(CU�5�/�Dy�����\s��fJ�@��*&���omt� 7U��������88.�"&öm7��.
��xY͇ؾ�mY�eٖe[�;�20���3'@PS�"�P�}�L��$g^��MM�ɧ���|{|�
�}���#�u�����lk�zۮ�e@�\
�eN�m�[f3S7b��	�<�G�#(�6d4S�������t��u�A���:��,C�(1#�q
�����zkk�56]Z�Ǿ�)��3G8��������h�`�9Q"u�@�D>U��އx@fc���BZ����������ǟ����ˤ�s�_K���Ç�ܞ��o�5���뭜.�<<�7�6�s�����)c�Y٦���H)[���)!�E�1����<M�V� �mD�4�8D܇�XJQ������Z�Ҷ�t��1� a�
b�t�\�i����S��ֻ,[W&�=�d���['bBSU15wP��â�z�����}��=��ۧ�q��
|��>�{����O����s.���2we����̠��]s������R8�	J�A�SJ�T<b���}�t�j�V���	9��f�vD�傪��{�=�u33$4�""�9"�9e:�Bܛ������h���>�f�N����X*<L�ms�#)c��jk�ۺ������v�����[�>w`�L�����r����RbQ�ZKeƈ�T/w�9�m	Dsuum%bq�̞��00����9e׽���9�@(u�+�8�{�I�D`��)!2#��R�C,"P���-v
qT�����.f�0_P�u�uӔ���m�tO��o��O�ڇ�����[$�/��<��k��ܟ�sMs*��|z���ϧ��[P CJ)�J)9m:��!�{�\��j�̌k�!6F�&
�\ID�u ���u3M)��Hx��TUE��Y�JLl�K�18�#n�3��ض�‘XM�U�ț��ǻw�����{�_��0`��N��Kɵ>|��͛�7��K�4].���4Wx��G�y��yN	�(b���s��S�5��|W�!������&n���)hW3%Nj�&��M�C�C0�������|| �ᡠJ���}�s���?~��T_��� ����n�������������y����Η9��kN8�w)Muʹ�DȄ*�
PJ.SA"�H�����J-��}[M-�j��ʡ�j��D�1�0�:Uo{3?<9�t��|�0�#D��sZ}LR*OO��|Z��>�=2����?����_V��X�٢����pww9�/SJ�ܧ�4����T���ĜԣNSI���v��SJ��S={����h�9�q����{�1�8�0� �Z��轫*"8�f�9��}V��wD�<��hO{�E��]o��ޯ/���|���W����n���ZJJ�ε^�K�J�i���i>Ւ�?NDL%eP�N\jabQ�#@�\O3 �*"��C�Trw�Wk�8d\��R��  "ș���%�#�55���xk���,��em?>��}���[]IDAT������'��|J9�\N���r>�RJ��� œkb,93��33�3橸���}P`�ӌ���UBA-М8%S;����1��\�����\�C-�ֽ_�[Dܿ9�[��޻�-��.�򲽼�g6:�
���;�l�<M����4��uJ�w����t.'p��b�rɽ�����nA%�PP݇JI��<]�W͠�z1���D��1z5$�G��
L���{S�6d�>�O/*���;�;�hS=]�i*�K=�7���:rJ4%�ħ�5S�Ԛ�i@d.[Z33��!''��� ��ffધӄl�!{6�m�(�#,[����p�.&���:z{7��'�_����!�ʥ�i*�<�N�V'�;fff��5���</8�Tj%B��ų��(%$��T��{��ZGQ� �-���elm컛����[�����L+�8e$�@������Mn~�P��a��0S��(�����m_vp��@
�q��m=��$�����1���ÐF%��ݛ��l"�hc�����
m�M�����a��������o�^�n�h��g���/�k}�������Z_�k}���;��#��~�lUIEND�B`��
	@�n��?" d�d@���������  @@``������q�7
	
"%

.

 !	#$%&'(	 		0-1)*+./23456789?��$���$��b�$�:@X�\�&#NZ	������0���A���A�p������������@����������N�g*@ʚ;62ʚ;�g��4dddd�n������������p�pp�@<�4dddd0���gʚ;<�4!d!d0���gʚ;��g��4WdWd�n���L?������������p�@p�p<�4BdBd0���gʚ;�\�� �___PPT10�����(��@��8��H��@�
�x	

��P	���	

���	

	

�"�X	
��P	��@���	

�!�P	�#�0���___PPT9������P�����p�������
�	

���	�� 	

���	

	

�"��	
���	�����`	

�!��	�#�`�h�___PPT2001�D�<�4X�������___PPTMac11�’@f �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typographyddd0���gʚ;<�4!d!d0���gʚ;��g��4WdWd�n���L������������p�@p�p<�4BdBd0���gʚ;�\�� �___PPT10�����(��@	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	��D �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�` �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�< �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�t �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�` �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�
� �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	�D �tnamdlCourier New&Monotype Typography	�� �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	�T �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	�"�	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�$
 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	�@ �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�� �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�!� �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�#H �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	( ��ʚ;�&�)ʚ;�d�d?��%�E3���LuaSocket behind the scenes�6	)���Diego Nehab��
�4��	Short Bio�

���Graduated from PUC in CS & E, 1999;
Worked in Tecgraf 1995-2002;
MSc in PL with Roberto, 2001;
3rd year PhD candidate at Princeton;
Computer Graphics.�D�A%�
��5��Outline of talk�
��~A few historical notes
Case study: SMTP support
Protocol abstraction
Message abstraction
Implementation highlights
Conclusions�p0C�
�
��Historical notes�
���1.0, 1999, 1.5k C, 200 man
1.1, 2000, 1.5k C, 1.3k Lua, 500 man
added protocol support for HTTP, SMTP, FTP
1.2, 2001, 2k C, 1.3k Lua, 900 man
buffered input and non-blocking I/O
UDP support
object oriented syntax�N@+#G@+#G�23KQ���Historical notes�
���1.3, 2001, 2.3k C, 1.6k Lua, 1.2k man
streaming with callbacks
added select function
1.4, 2001-2, 2.2k C, 2.2k Lua, 1.9k man
LTN7
added URL module
named parameters�l&/('&/(�o2���Current version�
��2.0, 2005, 4.6k C, 2.5k Lua, 4.7k man
Extensible C architecture, split in modules
LTN12 (sources, sinks and filters)
MIME support (partial but honest)
Multipart messages support
LTN13 (finalized exceptions)
Package proposal 
Improved non-blocking code, robust to signals...�p&d�d&,#"  ���6��Outline of talk�
��~A few historical notes
Case study: SMTP support
Protocol abstraction
Message abstraction
Implementation highlights
Conclusions�p0C���
�
��SMTP (RFC2821)�D!!��!�
��[lua:roberto] telnet mail.tecgraf.puc-rio.br 25
220 tecgraf.puc-rio.br ESMTP Sendmail 8.9.3/8.9.3
helo lua
250 tecgraf.puc-rio.br Hello lua, pleased to meet you
mail from: <roberto@inf.puc-rio.br>
250 <roberto@inf.puc-rio.br>... Sender ok
rcpt to: <diego@tecgraf.puc-rio.br>
250 <diego@tecgraf.puc-rio.br>... Recipient ok
data
354 Enter mail, end with "." on a line by itself
Subject: World domination: instructions.

Commence stage two.
.
250 RAA10452 Message accepted for delivery
quit
221 tecgraf.puc-rio.br closing connection�"�pnPZ02��	6��$*��$/��  1$$��@((+,,��00)44��88�,		"

��!��Protocol abstraction�
���status, error = smtp.send {
    from = "<roberto@inf.puc-rio.br>",
    rcpt = "<diego@tecgraf.puc-rio.br>", 
    body = "Subject: World domination: instructions.\r\n\r\n" ..
           "Comence stage two."
}��d�P'CcCcC6ccc C $$�								
						U	�&��
LTN12 sources�
���function ltn12.source.file(handle)
    return function()
        local chunk = handle:read(BLOCKSIZE)
        if not chunk then handle:close() end
        return chunk
    end
end�,#d�F�C�
��'��
Using sources�
���status, message = smtp.send {
    from = "<roberto@inf.puc-rio.br>",
    rcpt = "<diego@tecgraf.puc-rio.br>", 
    body = ltn12.source.file(io.open("/mail/body", "r"))
}��d�P)CcCc(CcC�								
						(	�,��Message Format (RFC2822)�,!���
��|   From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
   To: Diego Nehab <diego@tecgraf.puc-rio.br>
   Subject: World domination: roadmap.
   Content-Type: multipart/mixed; boundary=part
  
   This message contains attachments 
   --part
   Content-Type: text/plain
   
   Please see attached roadmap.
   --part
   Content-Type: text/html; name="roadmap.html"
   ...
   --part--�0}P�CC)CCCCCC  C 
$C$!(C(,c,0C04C48C8<C<CC�"[	�.��Message abstraction�
���declaration = {
    headers = { 
        subject = "World domination",
        from = "Roberto <roberto@inf.puc-rio.br>",
        to = "Diego <diego@tecgraf.puc-rio.br>"
    },
    preamble = "This message contains attachments.",
    [1] = {
        headers = { ... },
        body = "Please see attatched roadmap."
    },
    [2] = {
        headers = { ... },
        body = ltn12.source.file(io.open("/plans/roadmap.html", "r"))
    } 
}��<CCC
Cc0cc.c c $c$(C(,C,%0c04C48C8<C<CCCCcCCC C $C$E(c(,C,0C04C48C8�j3}	%	7	/E	
�1��Our message API�
���status, message = smtp.send {
    from = "<roberto@inf.puc-rio.br>",
    rcpt = "<diego@tecgraf.puc-rio.br>", 
    body = smtp.message(declaration)
}��dxP)CcCc'CcC�								
						'	�D"��How hard is it?�
���Message structure is recursive;
Need to return chunks but mantain context; 
Nightmare to write in C!; 
Use coroutines;
Write function recursively, naturally;
Call yield with each chunk;
Next call resumes wherever we left.���d ,7``a`
` a $`$((�"gv	�:��Zoom in on attachments�
���[2] = {
    headers = { 
        ["content-type"] = 'text/html; name="roadmap.html"',
        ["content-disposition"] = 'attachment; filename ="roadmap.html"'
    },
    body = ltn12.source.file(io.open("/plans/roadmap.html", "r"))
}��d�FCC	C4cIcCAcC C $C$�:"}	A	�;��LTN12 filters and chains�
��)Filters process data one chunk at a time;
MIME module provides common filters:
base64, quoted-printable, stuffing, line-wrap...
Can chain two filters together: factory
Produce a filter with the composite effect
Can chain a filter with a source: factory
Produce a source that returns filtered data.��O1(+*-*%1(+*,�
*�<��Zoom in on attachments�
��
�Q$��Creating filters: high-level�
��
�U&��Creating filters: low-level�
��
�S%��Creating filters: low-level�
��
�>��SMTP dependencies�
��
�A ��Error checking�
��DFunction return convention
Return nil, followed by message on error;�Bd*dA �
E�B��LTN13 exceptions�
��try = newtry(finalizer): factory;
On success, try returns all arguments;
On failure, throws the second argument;
Calls finalizer before raising the exception.
foo = protect(bar): factory;
foo executes bar in a protected environment;
Returns nil followed by any thrown error. ��"d}ddXdg��c`	``e��`.`	 a $`$(g(��,c,0`04e4��
8`8<e<d``a``��	u�C!��No 'if' statements�*`�"	��hInternal functions throw exceptions;
try calls tp.close() on error;
External functions can be protected.�xi%A
A
A  $$�
i�O#��Conclusions�
���Hope you like our API, we do;
It is easy to implement;
Function factories + clusures, coroutines
It is fast;
Time critical in C, management in Lua;
Questions?�l7*'*'��/������� �$�)�*	�-�/
�2�7�8�9�E�F�G�I�J�K�L�M�P�R�T�V����	I`� ����3�����f3��b��3��>��?" d�d@���������%�t��?" n��n���@���������� �@�`� �n��?" d�d@���������  @@``��P�R		 	@	`	�`�p�>��>�'�I���$��(	�
�$�
�$
��Z���������	�1�1Ȝ��Ȝ��?���@��>
�T�� Click to edit Master title style�!�
!�
�$
��6�������	?���� ��>
���RClick to edit Master text styles
Second level
Third level
Fourth level
Fifth level�!

�
S�`B
�$
s�*D�����1�"��������X�
�$
C�"��A�
moon"���� �`�H
�$��0�������޽h��	?� �������ff���b��3��D�<�___PPT10��.�.&��@��� �Custom Design�
�����P���*�(	��j`�j
���
��
��0��A|�����	�P ���
>���0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�P��*���
�
��
��0�`J|�����	��	� ���>���0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�R��*���
�d
��
c�$���	?��� 
��>�
��
��0��Q|�����	��
@����>
���RClick to edit Master text styles
Second level
Third level
Fourth level
Fifth level�!

�
S�
��
��6�@\|������	�`P����	>���0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�P��*���
�
��
��6��b|������	�`�	�����>���0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�R��*���
�H
����0���޽h������	?� ���������33������8�0�___PPT10��.��q��Z��� �`��(	�
�`��
�`
��0���O�����	�P ��
>
�X��*�����
�`
��0� �O�����	��	� ��>
�Z��*�����
�`
��6���O������	�_P��	>
�X��*�����
�`
��6���O������	�_�	���>
�Z��*����H
�`��0���޽h������	?� ���������33������8�0�___PPT10��.P����]�����O��'�O���0�$��L�(	�
���x
�� c�$�P
=��$����x	��>
���r
�� S��`�;��$��
` ���>
���R
�"�
s�*�������p��@�`B
�#�
s�*D�����1�"���X��X�X�
�$�
C�"��A�
moon"����	f
��H
����0�������޽h��	?� ���O�����f3��b��3������___PPT10�u�.�� �"z+D�='� �̐����=�
@B�	+���
�O��'�O���`�H�$�(	��.���1@��
�H�r
�H S��0���$���@��
>
���r
�H S������$����� ��>
���H
�H��0�������޽h��	?� ���O�����f3��b��3������___PPT10�u�.�� �"z+D�='� �̐����=�
@B�	+���
�O��'�O�����@�$�(	�
�@�r
�@ S���`���$���@��
>
���r
�@ S��@Q���$����� ��>
���H
�@��0�������޽h��	?� ���O�����f3��b��3������___PPT10�u�.�� �"z+D�='� ������=�
@B�	+���
�O��'�O�����-���(	�k����
���l
�,� C��`۸��$��@��
>
���l
�-� C���ܸ��$���� ��>
���H
����0�������޽h��	?� �������ff���b��3������___PPT10�u�.�q���+D�='� �̐����=�
@B�	+���
�O��'�O��������(	�{5
���l
�� C���}���$��@��
>
���l
�� C�� ���$���� ��>
���H
����0�������޽h��	?� �������ff���b��3������___PPT10�u�.
�q��+D�='� �̐����=�
@B�	+���
�O��'�O�M�E��	����(	����
���!��	�����
�	�������$�D,�P�H�___PPT2001�$�@F���
��
��0����������"��������X�P�H�___PPT2001�$�@F��w�
��
��<�@�����������'	�
�����0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�3��
David Burgess�
�
��
��0����������"���`����,$�D,��
��
��0����������"���8��x�$�D,�P�H�___PPT2001�$�@F��l
�� C���F���$��@��
>
���l
�� C���G���$���� ��>
���H
����0�������޽h��	?� �������ff���b��3��.�&�___PPT10��.�q��k�^z�+bk��D��
'� E�����=�
@B�	D�
'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D�4'� =�%�(�����D��'� =�%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*���������%�(�D�'� =�%�(�����D�f'� =�%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�hidden*�o3�>�+B�#style.visibility<��*���������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*	���������%�(�D�'� =�%�(�����D�f'� =�%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�hidden*�o3�>�+B�#style.visibility<��*	���������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*���������%�(�+���
�O��'�O�����8�$�(	��A
�8�r
�8 S������$���@��
>
���r
�8 S��P���$����� ��>
���H
�8��0�������޽h��	?� ���O�����f3��b��3������___PPT10�u�.�� �"z+D�='� �̐����=�
@B�	+�l�
�O��'�O��������f�(	�����ff���
�����l	��4�#
���<��#�,$�D,��
��
��6�����������"����P��X�P�H�___PPT2001�$�DF��
��
��<�������������4�#�����0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�F��from��
���l	����{	
������{	�,$�D,��
�	�
��6�����������"������h	�X�P�H�___PPT2001�$�DF��
�
�
��<������������-��{	�����0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�F��rcpt��
�f�l	��X�h

���X��h
�,$�D,�t
�
�
��6�����������"����X�h
�n
��
��<��������������������0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�*��body�
�r
�� S����$��@��
>
���r
�� S��p���$������>
���H
����0�������޽h��	?� �������ff���b��3����___PPT10���.�q�"r+����D�'� E�����=�
@B�	D�u'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<���8��H��@�
�x	

��P+D�4'� =�%�(�����D��'� =�%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*���������%�(�D�4'� =�%�(�����D��'� =�%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*���������%�(�D�4'� =�%�(�����D��'� =�%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*���������%�(�+�#�
�O��'�O�������\�(	��A$

���l
�� C��p���$��@��
>
���
�� ��<�������������	$����
��>
���
��
��6�0������	?�P
����,$�,
�~��What if body is large?�:d���
�H
����0�������޽h��	?� �������ff���b��3������___PPT10���.�qh�+�]%�D�O'� E�����=�
@B�	D�
'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D�A'� =�%�(�����D��'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*���������%�(�+8+0+�	+���
�O��'�O��� ��0�(	��.�p�1
��l
� C���&��$��@��
>
���
� ��<�0(�����������	$�P	��(�<$�D<�Π
���
�
��6�0�����	?����(
�h�`�P�___PPT10�0�(�v�___PPT9�X�P���___PPTMac11�\T �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
����pUse callback function that produces data;
Returns one chunk each time called;
Signals termination returning nil.�LqZNE��E�
q�H
���0�������޽h��	?� �������ff���b��3������___PPT10���.1�q���+���YD�O'� E�����=�
@B�	D�
'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D�A'� =�%�(�����D��'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*��������%�(�+8+0+	+�{�
�	O��'�O�$�0���(	�0B0A0B
��l
� C�����$��@��
>
���
� ��<��������������	$����h	��>
���p
�
��6��������	?��	��h�h$�,�4�H�___PPT10�(� �f�___PPT9�H�@�n�___PPTMac11�H@ �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
���What if body is complicated?�Bd`d��`�	�H
���0�������޽h��	?� �������ff���b��3������___PPT10���.3�q�F�+'�D�O'� E�����=�
@B�	D�
'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D�A'� =�%�(�����D��'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*��������%�(�+8+0+	+��9�
�O��'�O�.�&@� @���(	�
� �
� �
��6�����������"��������,$�@,�
� �
��6�����������"�������$�@,�P�H�___PPT2001�$�@F��
� 
��B������������"�������D$�,��0�___PPT10���6�___PPT9���H�___PPT2001�$�F��B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�-��headers�
�r
�  S�����$������
>
���
� 
��0�������"����
X8
�,$�@,��
� 
s�*������"���X��$�@
,�P�H�___PPT2001�$�DF��
� �
��6�����������"����
Mm�,$�@,�
� �
��0����������"���4M
�,$�@,�r
�  S������$��������>
���
� 
��<� �����������
�x��$�,���0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�-��headers�
�
� 
��<������������,r
��$�,���0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�*��body�
��
� 
��<�@�����������tXl�D$�,��0�___PPT10���6�___PPT9���H�___PPT2001�$�F��B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�,��part 2�
��
� 
��<�����������
����D$�,��0�___PPT10���6�___PPT9���H�___PPT2001�$�F��B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�*��body�
��
� 
��<�`���������etXL�D$�	,��0�___PPT10���6�___PPT9���H�___PPT2001�$�
F��B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�,��part 1�
�H
� ��0�������޽h��	?� �������ff���b��3���!��!�___PPT10��!�.3�q�F��S��+�f�D�d'� E�����=�
@B�	D�'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D��'� =�%�(�����D�'� =�%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�%�(�����D�R'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�hidden*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�hidden*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�hidden*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�%�(�����D�R'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�hidden*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�hidden*�o3�>�+B�#style.visibility<��* ��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�hidden*�o3�>�+B�#style.visibility<��* ��������%�(�+0+0+ 	++0+ 	++0+ 	++0+ 	++0+ 	++0+ 	++0+ 	++0+ 	++0+ 	++0+ 	+���
�
O��'�O���P�(�H�(	�
�(�r
�( S�� ���$���@��
>
���
�( ��B�P������������	$��������>
���H
�(��0�������޽h��	?� �������ff���b��3������___PPT10�u�.3�q�F�+D�='� �̐����=�
@B�	+��
�O��'�O���`�0��(	�
�0�r
�0 S��@�	��$���@��
>
���
�0 ��B�p�	�����������	$�����H	��>
���?
�0
��6���	�����	?��	��X���@�___PPT10� ��V�___PPT9�8�0�Z�___PPTMac11�4, �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
���UTransform declaration into an LTN12 source; 
Pass source as body to sending function.�0Vd-`(`�U	�H
�0��0�������޽h��	?� �������ff���b��3������___PPT10�u�.3�q�F�+D�='� n�����=�
@B�	+���
�O��'�O��������(	�
���l
�� C������$����
>
���l
�� C��0���$���� ��>
���H
����0�������޽h��	?� �������ff���b��3������___PPT10�u�.�q�꾖+D�='� �̐����=�
@B�	+�c�
�O��'�O�V�Np�P���(	�+R
�P�r
�P S����
��$��@��
>
���
�P 
��Z�д
������������	?$�����X
��>
���~
�P
��6��
�����	?��
����<�4�H�___PPT10�(� �f�___PPT9�H�@�n�___PPTMac11�H@ �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
����ZWould like to send PDF;
Binary data has to be encoded (Base64);
Want to encode on-the-fly.�>[d`(``�Z	�H
�P��0�������޽h��	?� �������ff���b��3������___PPT10�u�.	�q���+D�='� n�����=�
@B�	+���
�O��'�O�����X�$�(	�
�X�x
�X c�$��A��$���@��
>
���l
�X C��PC��$���� ��>
���H
�X��0�������޽h��	?� �������ff���b��3������___PPT10�u�.	�q���+D�='� �̐����=�
@B�	+�� �
�O��'�O�����\�6�(	�
�\�r
�\ S��0���$��@��
>
���
�\
��<�`����������	?�����4�,���___PPT10����	

�v�___PPT9�X�P	

���___PPTMac11��� �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	
�����[2] = {
    headers = { 
        ["content-type"] = 'application/pdf; name="roadmap.pdf"',
        ["content-disposition"] = 'attachment; filename ="roadmap.pdf"',
        ["content-description"] = 'Detailed world domination plan',
        ["content-transfer-encoding"] = 'BASE64'
    },
    body = ltn12.source.chain(
        ltn12.source.file(io.open("/plans/roadmap.pdf", "r")),
        ltn12.filter.chain(
            mime.encode("base64"),
            mime.wrap("base64")
        )
    )      
}��d�FCC	C9cIcCccc) c $C$(c(,c,*0c04c4#8c8 <c<
cccCC�:"�	�	�H
�\��0�������޽h��	?� �������ff���b��3������___PPT10�u�.�q�꾖+D�='� ������=�
@B�	+���
�O��'�O�V
�N
@����	�(	�
���x
�� c�$����$���@��
>
����
��
��<��y���������	?����H�$�D,���8�___PPT10���F�___PPT9�(� �R�___PPTMac11�,$ �tnamdlCourier New&Monotype Typography	
�U���function ltn12.filter.cycle(low, ctx, extra)
    return function(chunk)
        local ret
        ret, ctx = low(ctx, chunk, extra)
        return ret
    end
end
function mime.normalize(marker)
    return ltn12.filter.cycle(mime.eol, 0, marker)
end�.�P�CC
�
��A
��
��6��^�����	?����H� ��@�___PPT10� ��V�___PPT9�8�0�j�___PPTMac11�D< �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
���MChunks can be broken arbitrarily;
Filters have to keep context between calls;�4Nd"`+``�N	�H
����0�������޽h��	?� �������ff���b��3������___PPT10���.�q�꾖+���YD�O'� E�����=�
@B�	D�
'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D�A'� =�%�(�����D��'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*���������%�(�+8+0+�	+�&
�
�O��'�O��������_�(	�
���x
�� c�$�0I���$���@��
>
���
��
��<�@ʓ���������	?�����$�D,���8�___PPT10���F�___PPT9�(� �R�___PPTMac11�,$ �tnamdlCourier New&Monotype Typography	
����int eol(lua_State *L) {
    int ctx = luaL_checkint(L, 1);
    size_t isize = 0;
    const char *input = luaL_optlstring(L, 2, NULL, &isize);
    const char *last = input + isize;
    const char *marker = luaL_optstring(L, 3, CRLF);
    luaL_Buffer buffer;
    luaL_buffinit(L, &buffer);
    while (input < last)
        ctx = translate(*input++, ctx, marker, &buffer);
    luaL_pushresult(&buffer);
    lua_pushnumber(L, ctx);
    return 2;
}�.�F�CC
�
��H
����0�������޽h��	?� �������ff���b��3������___PPT10���.�q�꾖+���YD�O'� E�����=�
@B�	D�
'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D�A'� =�%�(�����D��'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*���������%�(�+8+0+�	+�
�
�O��'�O���`���L�(	�
���x
�� c�$� ���$���@��
>
���
��
��<��+���������	?�����$�D,���8�___PPT10���F�___PPT9�(� �R�___PPTMac11�,$ �tnamdlCourier New&Monotype Typography	
����#define candidate(c) (c == CR || c == LF)
int translate(int c, int last, const char *mark, luaL_Buffer *buffer) {
    if (candidate(c)) {
        if (candidate(last)) {
            if (c == last) luaL_addstring(buffer, mark);
            return 0;
        } else {
            luaL_addstring(buffer, mark);
            return c;
        }
    } else {
        luaL_putchar(buffer, c);
        return 0;
    }
}�<*FqA�CC
�
��H
����0�������޽h��	?� �������ff���b��3������___PPT10���.�q�꾖+���YD�O'� E�����=�
@B�	D�
'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D�A'� =�%�(�����D��'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*���������%�(�+8+0+�	+�V%�
�O��'�O�����
d���(	�
�d�x
�d c�$�`���$���@��
>
���
�d
��<��
�����������"����  ������0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�H��socket��
�
�d
��<�p

�����������"����@@��$�@,���0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�F��mime��
�
�d
��<��
�����������"���`	@@p��$�@,���0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�F��smtp��
�
�d
��<�
�����������"����@@���$�@,���0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�D��tp��
�
�	d
��<��
�����������"���`	``p�����0�___PPT10���6�___PPT9���B�___PPTMac11� �hnamd`
Arial&Monotype Typography	
�G��ltn12��
�
�d��0�������� @��,$�@,�
�
d��0��������@@`	�,$�D
,�
�d���0�������p@@��,$�@,�
�d@��0�������h
@`h
�,$�@	,�B
�d�
��6��D������@``	�,$�D,�B
�d@
��6��D�����p@`��,$�D,�H
�d��0�������޽h��	?O��ddd�dd
d�ddd�	ddd� �������ff���b��3��1�)�___PPT10�	�.�q�꾖+,�fD�)'� E�����=�
@B�	D��'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D�Y'� =�%�(�����D�'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*d��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*d��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*d��������%�(�D��'� =�%�(�����D�u'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*d��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*d��������%�(�D��'� =�%�(�����D�'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*d��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*d��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*d��������%�(�D�'� =�4@B��B��B��B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*
d��������%�(�+�+0+d	++0+d	++0+d	+���
�O��'�O����x��(	�
�x�l
�x C��0d
��$��@��
>
���l
�x C���e
��$	���	

���	

	

�"�X�������>
���w
�x
��<�pq
���������	?����@�$�D,�l���___PPT10���x	

��___PPT9����	

���___PPTMac11�xp �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	
�c���function metat.__index:greet(domain)
    local r, e = self.tp:check("2..")
    if not r then return nil, e end
    r, e = self.tp:command("HELO", domain)
    if not r then return nil, e end
    return self.tp:check("2..")
end��Z%CCcCCcCC C $c$(c($,c,0c04c48C8�RD		T	�	
�x
��6��}
�����	?�p�� �$�,���8�___PPT10���F�___PPT9�(� �F�___PPTMac11�  �hnamd`
Arial&Monotype Typography	
���-Tedious, error prone, virotic, not finalized.�".d-`�-	�H
�x��0�������޽h��	?� �������ff���b��3��h�`�___PPT10�@�.�q�꾖+�{ D�'� E�����=�
@B�	D�S'� ����=�
@B�A�?%�,(�	<�+O%�,(�
<�+D�A'� =�%�(�����D��'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*x��������%�(�D�A'� =�%�(�����D��'� =�%�(�D�'� =�A@B��B��B��B�0B�%�(�D�'� =�1�:�B�visible*�o3�>�+B�#style.visibility<��*x��������%�(�+p+0+x	++0+x	+���
�O��'�O�����t��(	�
�t�l
�t C���!��$��@��
>
���l
�t C���#��$���� ��>
���H
�t��0�������޽h��	?� �������ff���b��3������___PPT10�u�.�q�꾖+D�='� �̐����=�
@B�	+�,
�
�O��'�O�� �|��(	�
�|�r
�| S��c���$���@��
>
���

�|
��<�0n����������	?����-	�\�T�x�___PPT10�X�P	���___PPT9����	���___PPTMac11��� �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	
����function metat.__index:greet(domain)
    self.try(self.tp:check("2.."))
    self.try(self.tp:command("HELO", domain))
    return self.try(self.tp:check("2.."))
end���Z%CCcCCcc)c c $C$�:@	;	�l
�| C��2���$��	�� ��>
���H
�|��0�������޽h��	?� �������ff���b��3������___PPT10�u�.�q�꾖+D�='� ������=�
@B�	+���
�O��'�O��� ����(	�
���r
�� S���=���$���@��
>
���l
�� C���m8��$���� ��>
���H
����0�������޽h��	?� �������ff���b��3������___PPT10�u�.�q�꾖+D�='� �̐����=�
@B�	+���n�f@����(	�@
���R
�� 3������� 
��>�l
�� C����|�����
@����>
���H
����0���޽h������	?� ���������33������8�0�___PPT10��.��q��Z���
t�l�����(	�
���R
�� 3������� 
��>�r
�� #��������
@����>
���
�H
����0���޽h������	?� ���������33������8�0�___PPT10��.�q�T6����t�l�����(	�
���R
�� 3������� 
��>�r
�� #��@R����
@����>
���
�H
����0���޽h������	?� ���������33������8�0�___PPT10��.�q�T6���������(	���p�`�
���R
�� 3������� 
��>�
�� C��p�	�����
@���X�>�@�P�___PPT10�0�(�v�___PPT9�X�P�b�___PPTMac11�<4 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
�Y���David, who lives in Melbourne, knows RFCs by experience, whereas I only read them.
First FTP server written back in 89...
My inbox has about 700 messages from him.
He wrote all of them while being upside-down, which always strikes me as odd.�:�S&+M�
��H
����0���޽h������	?� ���������33������8�0�___PPT10��.�q�T6����
s�k����(	� )� )�
���R
�� 3������� 
��>�q
�� C���>I�����
@����>���@�___PPT10� ��V�___PPT9�8�0�J�___PPTMac11�$ �hnamd`
Arial&Monotype Typography	
����What is SMTP anyways.
Text mode protocol. Send commands, read back replies.
FTP also uses the same underlying command structure, and the implementation of the two modules share a subsystem.�&�5s�
��H
����0���޽h������	?� ���������33������8�0�___PPT10��.�q�T6��*	���0���:�(	�
���R
�� 3������� 
��>�
�� C��0`�����
@����>�|�X�___PPT10�8�0���___PPT9�h�`���___PPTMac11�`X �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
����6Here is the simplest interface we can come up with. We can add some sugar, such as the multiple-recipient list, passed as a table.
It works well for small, static messages.
But what if the content is large. Messages with attachments can be several megabytes long.
We don't want to load all that up into memory.�H7�*[(`�"(	�H
����0���޽h������	?� ���������33������8�0�___PPT10��.�q�U����	�^	�V	@����(	�
��R
� 3������� 
��>�\
� C���#`�����
@����>�����___PPT10�`�X	
���___PPT9����	
���___PPTMac11�d\ �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
��� The idea we use in LuaSocket is to pass a function instead of a string.
This function will be repeatedly called whenever the SMTP module needs data to send.
The protocol to these so called "source" functions is formalized by LTN12.
As an example, consider a source that produces the contents of a file.
This is actually a factory: a function that creates and returns custom functions.
Hail Lua, where functions are first class citizens.
Here we are also taking advantage of Lua's lexical scoping to store the context between calls (file handle)�~!HT!*`GR3)  $`$A((�:�*	�	A�H
���0���޽h������	?� ���������33������8�0�___PPT10��.��q�,����Z�RP����(	�
��R
� 3������� 
��>�X
� C��0Y`�����
@���H�>�0�P�___PPT10�0�(�v�___PPT9�X�P�R�___PPTMac11�,$ �hnamd`
Arial&Monotype Typography	
���<Here is how we can use a file source with the SMTP module.
Nothing is really loaded into memory until the module needs data to be sent. Even then, the source can control the granularity.
But what if the message is complicated? We don't want our users to be forced to know all the details and write a file to be sent.�>=;�.S`�"�S	�H
���0���޽h������	?� ���������33������8�0�___PPT10��.��q�,����R�J`�$���(	�
�$�X
�$C������� 
��>�J
�$S���n`�����
@����>�l�X�___PPT10�8�0���___PPT9�h�`�v�___PPTMac11�PH �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
�p���How complicated can it be? Here is an example of multipart message.
<<describe parts>>
We want to be able to describe a message like this, without creating it in memory.
Roberto would never send me a message with an HTML file attached, but bear with me.
�D�DST�
��H
�$��0���޽h������	?� ���������33������8�0�___PPT10��.��q�,��,���p�,�<�(	�
�,�X
�,C������� 
��>�
�,S��0�`�����
@���,�>��H�___PPT10�(� �f�___PPT9�H�@�N�___PPTMac11�(  �hnamd`
Arial&Monotype Typography	
�"���Good thing Lua was designed as a description language.
Notice the ltn12 source doesn't load anything into memory.
But how to send the message we have just declared?�8�)`m`�"�	�H
�,��0���޽h������	?� ���������33������8�0�___PPT10��.��q�,�������4��(	���
�4�X
�4C������� 
��>�
�4S����`�����
@����>
���
�H
�4��0���޽h������	?� ���������33������8�0�___PPT10��.��q�,�������<��(	��
�<�X
�<C������� 
��>�
�<S���$	�����
@����>
���
�H
�<��0���޽h������	?� ���������33������8�0�___PPT10��.��q��Z�U	������D�e�(	���
�D�X
�DC������� 
��>��
�DS����������
@���p�>�X�`�___PPT10�@�8���___PPT9�x�p�J�___PPTMac11�$�� x	�� x	�� x	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
����We start with a few historical notes on LuaSocket
Then we move on to our case study which is the SMTP support shipping with the newest versions. 
We will focus on little details of Lua that enables us to taylor a very elegant interface to sending e-mail messages.
I realize my abstract mentioned more stuff.  For some reason I had in mind it would be a longer talk, so I had to downsize.�N�2_vr	�(\�H
�D��0���޽h������	?� ���������33������8�0�___PPT10��.��q��Z���z�rp�L�
�(	��@�
�L�X
�LC������� 
��>�r
�LS��`O~�����
@����>
���H
�L��0���޽h������	?� ���������33������8�0�___PPT10��.��q��Z�9������I�(	�
���R
�� 3������� 
��>�
�� C��P,a�����
@���H�>�0�P�___PPT10�0�(�v�___PPT9�X�P�R�___PPTMac11�,$ �hnamd`
Arial&Monotype Typography	
����The solution LuaSocket adopts is given by LTN13. 
We use Lua's error reporting to implement an exception mechanism with two tiny helper function factories.�>�2_`�"<_	�H
����0���޽h������	?� ���������33������8�0�___PPT10��.�qI���.�"������>�(	�
���R
�� 3������� 
��>�
�� C���a�����
@����>
�L��&About 100 lines of nice, modular code.�
'�H
����0���޽h������	?� ���������33������8�0�___PPT10��. �q����O�!������_�(	�
���R
�� 3������� 
��>��
�� C���8a�����
@����>
�m��GAll SMTP code, with error checking fits in 100 lines of clean Lua code.�
H�H
����0���޽h������	?� ���������33������8�0�___PPT10��. �q�qO����������(	�
���R
�� 3������� 
��>�	
�� C��0�`�����
@���h�>�P�P�___PPT10�0�(�v�___PPT9�X�P�r�___PPTMac11�LD �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
�Q���Roberto would actually send me a PDF;
But PDF files are binary, and SMTP is text mode.
Need to encode as BASE64 before sending.
Want to do everything on the fly, with the same requirements: not allowed to load everything into memory.�:�&1)i�
��H
����0���޽h������	?� ���������33������8�0�___PPT10��.��qGr��.�������>�(	�
���R
�� 3������� 
��>�
�� C����`�����
@����>
�L��&Introducing LTN12 filters and chains.
�
'�H
����0���޽h������	?� ���������33������8�0�___PPT10��.��qGr����C�;������(	�{5�v
���R
�� 3������� 
��>�A
�� C��0�`�����
@����>���8�___PPT10���F�___PPT9�(� �V�___PPTMac11�0( �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
�����Once again, nothing happens until this message is sent. And even then, things happen chunk by chunk.
Filters are great to use, but how hard is it to write filters?��e?�
��H
����0���޽h������	?� ���������33������8�0�___PPT10��.��qGr��v	���������(	�{5
���R
�� 3������� 
��>��
�� C���a�����
@����>�|�X�___PPT10�8�0���___PPT9�h�`���___PPTMac11�`X �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
����Two of the involved modules have no depencencies.
Socket and LTN12. Socket implements the core comunications capabilities. LTN12 implements that technical note functionality.
The tp module implements the command/response structure common to SMTP and FTP (and not by HTTP)
The MIME module implements the encodings commonly used by SMTP
The SMTP implements the message abstraction, and message sending functionality.�D�2}a?O�
��H
����0���޽h������	?� ���������33������8�0�___PPT10��.��qGr��x� ��������(	�
���R
�� 3������� 
��>�
�� C��%a�����
@���h�>�P�P�___PPT10�0�(�v�___PPT9�X�P�r�___PPTMac11�LD �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	
�>���This is the error convention has been adopted throughout LuaSocket and many other libraries.
If a function succeeds, it returns whatever it is that it should return.
If it fails, it returns nil, followed by an error message. I subscribe to this idea, but it can be challenging to implement code that conforms to it.
The reason is that each function might perform many operations, and there can be several layers of functions.
There would be a lot of code like the above.�:�]�n,�
��H
����0���޽h������	?� ���������33������8�0�___PPT10��.��qGr���#��0����(	���
���X
��C������� 
��>�
��S����Z�����
@����>
���
�H
����0���޽h������	?� ���������33������8�0�___PPT10��. �q�qO����$A�9P�����(	���
���X
��C������� 
��>�9
��S��0�������
@����>���@�___PPT10� ��V�___PPT9�8�0�J�___PPTMac11�$ �hnamd`
Arial&Monotype Typography	
����LTN12 describes a series of tricks on how to implement these ideas.
We see here the code for an end-of-line marker translator.
�&�D:�
��H
����0���޽h������	?� ���������33������8�0�___PPT10��.��qGr��|�%���p����(	���
���X
��C������� 
��>��
��S��&������
@����>
���hWe talked about lots of different modules, so lat zoom out a little and take a look at the dependencies.�
i�H
����0���޽h������	?� ���������33������8�0�___PPT10��.��qGr��X�&�������h�(	�
���X
��C������� 
��>��
��S��P������
@����>
�j��DLTN12 describes a series of tricks on how to implement these ideas.
�
E�H
����0���޽h������	?� ���������33������8�0�___PPT10��.��qGr�cx��p^�RЀ3ÿ��lHb�P@���AL
�G�����@;b`B��&V�<�Wq�o���2�#��D@��4C�~wl�r ���]� ��&B���
V#DFH�N�8$�S& �?�L) �\�f,@wX�l�nt1 ޔ�y4�.�� �{�}'�������>\�Ap��/O2�)�j���I���������	�J��?��^���A�f����!���Vٰ���(����
�F/�0��|�DArial�0�0w���������	I��������@\P^�\!�DTimes�0�0w���������	I��������@\P^�\! �DCourier New���������	I��������@\P^�\!0�DWingdingsw���������	I��������@\P^�\!@�D-�3� 0��0�0�0�0w���������	I��������@\P^�\!��
�`�����.	
��P	��@���	

�!�P��
��Oh��+'��0Thp���	��
��
�'Slide 1
Steve Overbyb})�Diego Nehab75�Microsoft PowerPoint@���L�@���
��@�VMX��&G<����PICT4�����HH��
��������HH  t�L�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������7����8GQVTI:(�� >LTZXM>,�� :DKPOG9(�C����1�}h`cfimmfT(��8��ze`cgjonhV-��8��jXTX[^ba\M+�O����"s��mf__j�xrs{�i)��)x��jd__j�xqsx�n0��'r�y^VSS^t}legktd/�U����L��y_aecgp|�{v�����W	��	S��t\`dcgnz�ys~����`
��R��eRTWU[amtlho~���^
�X����_��cfdgr}�yptwsz����u��e��{`ccgs{}vortqu����~��a��jTYWYflmhbfhber���{�\����V���uhffy��vxtspkf{���p��^���odcdv��|uwspnicu���y��^���a�Wi��lfjhea\Ub���w�a����?���~lkl|�����{vpjhh����Q��GǺ��zggiw�����xsmife{���]��Fİ�ykZZ\iwv|�{lha\XVi���`�g�����ĺ���|ru|������yspqty���� ��������umqw�����}upmmot����)��������f]cjs����nhd`^_c{���-�g����s������w���������||xw|~���Ɏ��z������p{��������yxtswx���Ù��v���vuycmxqz����tjjfeggp�����m����&��Önj|v������������y������-��,����hevp|�|������}~~sz������8��,���XYgamoly����nnogknu����=�m����i����q����z������������������t��o����l|��zu�������~������������l���u]p�yldv�{r~��pr�x{�������s������������������~{{�����������������������������{xx���������������
�����~w�qr��umjju������������s����$���������������||������������)��*���������������x}x������������2��*�����zwzrs{x{�qjni|���y�������2�s����A�������|}}��������{���|z������I��F�������vww}�������v��|wt������S��E�������gfgmv���~�xhqvjfer��~t�S�s����^�����Ŭ|w���������t�vioq~�����d��d�������sqz��������p}rdkjw�����o��a�������eajv������wbndU\\f��s�o�s����t�����Ͻ�������������|prr{�����_��z�����Ƴ�����������~�xknmt�����i��v��������q���������ouj[^]co}���g�s����pǵ�����λ�������Ƿ���wrqr�����L��w�������ı������������qmmn}����V��v������ɺ������������xa]]_l{���S�s����dȽ�������ƾ�������zvlje|�����3��mø������ȼ���������ysifaw�����<��m�������ڿ����������mfYWRfp���9�s����I��������˼����¹�p]]ei}������!��Rļ������Ϳ��������p_\cgx������)��T��������Ų��������fTQWYg�����&�s����(����������ɿ�����fbcb�������|
��/���������¾����ȼgaca|���������0�������Ž��������t]VWTm������t�r���������������ý��ų�e]\_p������Z��	������������¿�e][^n������b�������¼���������tYRPQ`w�����Z�m����b�������ž���ε�yqgZUh������0��lǼ�����������Ư�vneZUe������8��l����������������j`WNHV�����5�m���������������ª���ta^������a��%������������¾����s^[������g��&������������������fRPn����|]
�g����fǹ��������Ű�����zpz��zw��)��rĴ���������������vmu��zv��0��t����������������i_f��pg}x-�f���������������������ru��lX_�I������������������os��nX^�Q��������������or��scep�aLPsK�a����,��������������h^[��[MbY	��5��������������h]Z��ZK__
��3��������������rZQLnxN?QV
�[����-�������������k]WW��xpU��5�������������j]XU��unZ��4�������������]QLJrwf`Q�U����2������������skdctkmF��:������������phbbrknL��7z���������sqa[VTe_aE�R����\���������}��yph[1��b���������{}�vnh^5��Zs�������ymnyj`\R1�I����"Ou������xz{nY3��%Tw������xy{n\8��"Ljw����ylkodS2�<����7Thqng`VG,��
;XluqidZM2��
6Pclg`ZRF-�+����
��
��
�����������������������������
��
��
�V����8�3�����5�T�
�SM�8�3�����5�T�
�SM�8�3�����5�T�
�SM�^����;�6�>�^2ӱ�T�
��h�;�6�>�^2ӱ�T�
��h�;�X�>�m\��T�8��o������;�6�-�F��X���'��=!/x��yQ��T���;��}���N�;�6�-�F��X���'��=!/x��yQ��T���;��}���N�4;�j)�F��X���'��iGb8x��yQ��T�Q��;��}���l������;�6�-�O��hG(�^e��fQ�R9�T�s!�.T���͈�@�{�;�6�-�O��hG(�^e��fQ�R9�T�s!�.T���͈�@�{�5;�l*�i��$nQJ�~m��x W�^[�l�zA�R\���4,Ѝ8�\��T%������;�6��R��o��k'H*������>�$�
T���
����x�h�;�6��R��o��k'H*������>�$�
T���
����x�h�6;�m*�{-��:y���LQ'`��7��95ǺZ�K6(4e���J=����!��D������3;�[//&�s��]�mE�d(��
W�G-�W	�w�DT�%܍��2�v�3;�[//&�s��]�mE�d(��
W�G-�W	�w�DT�%܍��2�v�5;��Q5&��<�I�nG��l�s=��Ph�zI�y?�E�OZ�c� �N�l2�>������;��.����ħ���ۏ���Y���`��T�
N�-X����d�;��.����ħ���ۏ���Y���`��T�
N�-X����d�;��0�	���ǹA���߮8���vP ���?5l�)f�Pt�Va���<$���������
�
���	�
���
�
���	�
��6FOGD;9H>FB;G>L;.MDJ=	3FA?$DAAI#$B 'KCA@K*	�D��������/


�������������������7������������������������������:�������������������)�������������������������������������������������������=��R��?��?�R��Y��?��,��?��?��?�n������������������������������������������^��\�H��J�\��\��Z��\��Z�<�������?HV^�_% B\_ B28THB\__.S^27AU^__ B\__KV^�:��������


	
�

���������������������������������������������������������������������������������������������������������C���������������������������������������7������������������������^������������������������������������������������O������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
��՜.��+,��00�������	�
�����
��On-screen Show�6��F ArialTimesCourier New
WingdingsMS PゴシックCustom DesignLuaSocket  behind the scenes
Short BioOutline of talkHistorical notesHistorical notesCurrent versionOutline of talkSMTP (RFC2821)Protocol abstractionLTN12 sourcesUsing sourcesMessage Format (RFC2822)Message abstractionOur message APIHow hard is it?Zoom in on attachmentsLTN12 filters and chainsZoom in on attachmentsCreating filters: high-levelCreating filters: low-levelCreating filters: low-levelSMTP dependenciesError checkingLTN13 exceptionsNo 'if' statementsConclusions	�#�0���___PPT9������P�����pR����������d�O�����)���;�6���Pictures���������PowerPoint Document(���������SummaryInformation(���������������������������������������������������������������������������������������������������������������������������������������������������������������	

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopr�stuvwxyz{|}~�������������������������������������������������������������������������������������������������������������������������������quf	

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde����ghijklmnopqrstv�wxyz{|}~�DocumentSummaryInformation8������������`Current User������������A������������������������	

��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Fonts UsedDesign Template
Slide Titles�#_���ǫ�"DDiego NehabDiego Nehab�������
�	

���	�� 	

���	

	

�"��	
���	�����`	

�!��	�#�`�h�___PPT2001�D�<�4X�������___PPTMac11�’@f �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	��D �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�` �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�< �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�t �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�` �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�
� �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �	

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	�D �tnamdlCourier New&Monotype Typography	�� �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	�T �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	�"�	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�$
 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	 �tnamdlCourier New&Monotype Typography	�@ �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�� �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�!� �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	�#H �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	 �hnamd`
Arial&Monotype Typography	( ��ʚ;�&�)ʚ;�d�d?��%�_3���LuaSocket behind the scenes�6	)���Diego Nehab��
�4��	Short Bio�

���Graduated from PUC in CS & E, 1999;
Worked in Tecgraf 1995-2002;
MSc in PL with Roberto, 2001;
3rd year PhD candidate at Princeton;
Computer Graphics.�D�A%�
��5��Outline of talk�
��~A few historical notes
Case study: SMTP support
Protocol abstraction
Message abstraction
Implementation highlights
Conclusions�p0C�
�
��Historical notes�
���1.0, 1999, 1.5k C, 200 man
1.1, 2000, 1.5k C, 1.3k Lua, 500 man
added protocol support for HTTP, SMTP, FTP
1.2, 2001, 2k C, 1.3k Lua, 900 man
buffered input and non-blocking I/O
UDP support
object oriented syntax�N@+#G@+#G�23KQ���Historical notes�
���1.3, 2001, 2.3k C, 1.6k Lua, 1.2k man
streaming with callbacks
added select function
1.4, 2001-2, 2.2k C, 2.2k Lua, 1.9k man
LTN7
added URL module
named parameters�l&/('&/(�o2���Current version�
��2.0, 2005, 4.6k C, 2.5k Lua, 4.7k man
Extensible C architecture, split in modules
LTN12 (sources, sinks and filters)
MIME support (partial but honest)
Multipart messages support
LTN13 (finalized exceptions)
Package proposal 
Improved non-blocking code, robust to signals...�p&d�d&,#"  ���6��Outline of talk�
��~A few historical notes
Case study: SMTP support
Protocol abstraction
Message abstraction
Implementation highlights
Conclusions�p0C���
�
��SMTP (RFC2821)�D!!��!�
��[lua:roberto] telnet mail.tecgraf.puc-rio.br 25
220 tecgraf.puc-rio.br ESMTP Sendmail 8.9.3/8.9.3
helo lua
250 tecgraf.puc-rio.br Hello lua, pleased to meet you
mail from: <roberto@inf.puc-rio.br>
250 <roberto@inf.puc-rio.br>... Sender ok
rcpt to: <diego@tecgraf.puc-rio.br>
250 <diego@tecgraf.puc-rio.br>... Recipient ok
data
354 Enter mail, end with "." on a line by itself
Subject: World domination: instructions.

Commence stage two.
.
250 RAA10452 Message accepted for delivery
quit
221 tecgraf.puc-rio.br closing connection�"�pnPZ02��	6��$*��$/��  1$$��@((+,,��00)44��88�,		"

��!��Protocol abstraction�
���status, error = smtp.send {
    from = "<roberto@inf.puc-rio.br>",
    rcpt = "<diego@tecgraf.puc-rio.br>", 
    body = "Subject: World domination: instructions.\r\n\r\n" ..
           "Comence stage two."
}��d�P'CcCcC6ccc C $$�								
						U	�&��
LTN12 sources�
���function ltn12.source.file(handle)
    return function()
        local chunk = handle:read(BLOCKSIZE)
        if not chunk then handle:close() end
        return chunk
    end
end�,#d�F�C�
��'��
Using sources�
���status, message = smtp.send {
    from = "<roberto@inf.puc-rio.br>",
    rcpt = "<diego@tecgraf.puc-rio.br>", 
    body = ltn12.source.file(io.open("/mail/body", "r"))
}��d�P)CcCc(CcC�								
						(	�,��Message Format (RFC2822)�,!���
��|   From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
   To: Diego Nehab <diego@tecgraf.puc-rio.br>
   Subject: World domination: roadmap.
   Content-Type: multipart/mixed; boundary=part
  
   This message contains attachments 
   --part
   Content-Type: text/plain
   
   Please see attached roadmap.
   --part
   Content-Type: text/html; name="roadmap.html"
   ...
   --part--�0}P�CC)CCCCCC  C 
$C$!(C(,c,0C04C48C8<C<CC�"[	�.��Message abstraction�
���declaration = {
    headers = { 
        subject = "World domination",
        from = "Roberto <roberto@inf.puc-rio.br>",
        to = "Diego <diego@tecgraf.puc-rio.br>"
    },
    preamble = "This message contains attachments.",
    [1] = {
        headers = { ... },
        body = "Please see attatched roadmap."
    },
    [2] = {
        headers = { ... },
        body = ltn12.source.file(io.open("/plans/roadmap.html", "r"))
    } 
}��<CCC
Cc0cc.c c $c$(C(,C,%0c04C48C8<C<CCCCcCCC C $C$E(c(,C,0C04C48C8�j3}	%	7	/E	
�1��Our message API�
���status, message = smtp.send {
    from = "<roberto@inf.puc-rio.br>",
    rcpt = "<diego@tecgraf.puc-rio.br>", 
    body = smtp.message(declaration)
}��dxP)CcCc'CcC�								
						'	�D"��How hard is it?�
���Message structure is recursive;
Need to return chunks but mantain context; 
Nightmare to write in C!; 
Use coroutines;
Write function recursively, naturally;
Call yield with each chunk;
Next call resumes wherever we left.���d ,7``a`
` a $`$((�"gv	�:��Zoom in on attachments�
���[2] = {
    headers = { 
        ["content-type"] = 'text/html; name="roadmap.html"',
        ["content-disposition"] = 'attachment; filename ="roadmap.html"'
    },
    body = ltn12.source.file(io.open("/plans/roadmap.html", "r"))
}��d�FCC	C4cIcCAcC C $C$�:"}	A	�;��LTN12 filters and chains�
��)Filters process data one chunk at a time;
MIME module provides common filters:
base64, quoted-printable, stuffing, line-wrap...
Can chain two filters together: factory
Produce a filter with the composite effect
Can chain a filter with a source: factory
Produce a source that returns filtered data.��O1(+*-*%1(+*,�
*�<��Zoom in on attachments�
��
�Q$��Creating filters: high-level�
��
�U&��Creating filters: low-level�
��
�S%��Creating filters: low-level�
��
�>��SMTP dependencies�
��
�A ��Error checking�
��DFunction return convention
Return nil, followed by message on error;�Bd*dA �
E�B��LTN13 exceptions�
��try = newtry(finalizer): factory;
On success, try returns all arguments;
On failure, throws the second argument;
Calls finalizer before raising the exception.
foo = protect(bar): factory;
foo executes bar in a protected environment;
Returns nil followed by any thrown error. ��"d}ddXdg��c`	``e��`.`	 a $`$(g(��,c,0`04e4��
8`8<e<d``a``��	u�C!��No 'if' statements�*`�"	��hInternal functions throw exceptions;
try calls tp.close() on error;
External functions can be protected.�xi%A
A
A  $$�
i�O#��Conclusions�
���Hope you like our API, we do;
It is easy to implement;
Function factories + closures, coroutines
It is fast;
Time critical in C, management in Lua;
Questions?�l7*'*'�,V.
/������� �$�)�*	�-�/
�2�7�8�9�E�F�G�I�J�K�L�M�P�R�T�V����
����'�����P����(	�
���r
�� S���t��$���@��

���l
�� C����t��$���� ��
���H
����0�������޽h��	?� �������ff���b��3������___PPT10�u�.�q�꾖+D�='� �Ɛ����=�
@B�	+r�O��#����VӰPKN��\l����-�-
luasocket.pngnu�[����PNG


IHDR��L\��-SIDATx��}ytTE����k��F�J�B�����
��Q>uqA�~��:Χ~�93Ό��0�Dp?$
Q�%İ$�$BHB�JI�,�^U�����ѝ�tBH���{��t^�W��ު{oݭ�~������~$@?Ï�g���?���G�3�H�~��;�Cp߾ ���S=����Fq����w�{c�O!탽�%�&p���:ހ�||�w���\�|�x�b����#�`��A)B|���H/XS��ٳ����R�p8t:��?l2�c�W����X,����X,���mAK߉�E=!��lJM���Ł
4DD��t�q_��,H;ߵ�B�円����.�?~�������`dY6�Lc��HQ������v��n�[�֟��'�/VTq�R9U�470�9璄[Z;wm�^��_S[�"�]tt@ZZ�}���7/Q�'�2�co��
P���b"���������ƍ����e�����.]�$)**Jc�gϞ���I�&����F_8��}@����^�_]}	Hp�d4th�k�͹�JB�
��Z�"�rEEE\\�$I�'�����Eq��*�4�����F��c����������!����322L&�Jx���S�P��

m<�c����c��]�?�|����S����:���:������w����)��z�ꠠ <2���uׂ:�S���c�6[[[KKK.\�J-i�#�+cT]m���/J�?���
�c�b�3gԮ]�e2�pՎ���h�����ܹ3,,l�ĉ�ƍ�X,*"T����Ls�|�/\�qqq���M�9s�ѣe��(��� ����՟�l¶m�1�U%U{y饗���/�EIHHX�x��
��L@�XzK/FtF�|�3�ڲeKCCCtt�����IL�g�ٳs�	�.@Q��;���$���BB��Q�1v�M_.󮥥E���zuA�['�d�t���ݖ��dffVUU����s�=��9R9y�{����c��Ƃ�_FG[�:Ў�ۂT,c��=�ꫯ�>}4�Z�F�G��Q�e�q�V�Z���9֮��s���@�sB�������P�\�y#Tg֥K��o�^^^>w�ܩS�
�w�Xo:݋ե��:l��MM�OV��#"

V��s_�Y����)����Κ5K�?��>��Y�vFH�w�ٚ�[��tc���9��3g�Ϝ�n���w�Z%G�J�T����}���޴�/��)6��i�E��@AA-��s߁D��̙K��.��Mh%���(22�1&$�V��5�A�0F�`������P�������O2�m/^�qF�`��W�͐�k�b�RXXh6����U-�lj�Ż�P�tUR�lJe�ժ����m

mmm��A@�'&�n�SX�ߠA���11�I�S�cN��m6��Pd�S����8焐�G�n޼9##C���j8*F�	K/B!T_ߚ�[y���cǪΝk���R�P<�$@"D��2qb�)���b��1�+p�a��~~����IS�,0�عs��?y�dU���#aŭ�h���>���ȑJ��
@�� ��X�Y!?)e��W*+�����L��`AʂC���
��y"��� >>H����׀1���m
�����;�y��e˖�=Ze;]�^�1F#Y�{���_���W%6[�aL�1�����1
 0��o���?~�^O���I��*�;�_nDpIBg�29y���I�%�ʕ+W�\ILL���b#�����x#�����Ӎ!QJ����zu�����ӫ}�jF��&���kkj��`'�1b�>iR�#+�m�7�p�\��!!!			�`_h��"�"|�#�}�m��5�1	d���RN)@��06�;W�r�Ç��~}�@VƘ�b�‚���
��h'N��<�����{�<�/�d.v���W�Z�'/�<B�ut��þ͘�s���C�zk����j��=ƨ���رﴴP���-$�3&'$��8�ˀ}���rYZZ����C0�N��V���ە_��������CHO)��b�SJ��/(��1c�O�nmu���(
KLy��Ym:]��ŝ�V��y��-=!�:�1ƭ���6m:w��O	�v�H����}w?!:��N��u1�R�
�����ر벳+$	S�;"1Ɵ}6}��	�l��$'r�.BH�ÔZ׬��x�pJƝ��'��6m����d��'/�g�S�u:��;G�N}���:B�)�~4�!������i�����$	f(��|ӦEw�9F��%Il�=�A����,[�zj�k�ݡb�?=\�������K�.�$I��N%�֩�1z����`�����a?`!W�c=��3��\��3aA^u�A�#���K~��;�N�
!�$B��pt|A�D┶b�����w���ͨU��۷/00p„	�������V�g?����(���� ��T�/��c�1�b{�q�$aE�Ξ=rǎ�-���1H>|���<X
`w�
�(`���{��8k��0Eaޣ�zHO!^���l��M��g%ɿo�߁z��v���3����j�˲
@�a����AˤI	_|��P��`Jb:��U��Y��s���Q
�JH�>=>#cXrr������
�{-��*�Y��y�>��)�$?E�}9�]m�錳f%-\�2qbTt��l�Qʚ�l��]��۲�����!	!=c$�(J�ĉ�����@@��"�d���+�٬s^Y6��
@m�{l�z�,�;���ׅ������
���>��g��pﳊ��ۋ^x����B̔r.h0mZ�޽�=�47	���P/�1>��m��
am����kkk;�պ)��G��_��1��hع��[''�R��vW����2%���S�V>��J��(T���a����W]�:]��J�a�t:R_��o�_�u7D���g��ڵ����K�N��	���z`��#�2����,>�pa�,S��X�~A:{.��lذ�W�Sj�9i�u�_�G�T����
�oooߵkWIII�؇n��wlڴ)99yڴi���΀&I83��c���贁��`����{��!�T���-������͜9��E��9G�0�ƆΦ�F�1Pl㽘�����\�RPP������t�V���N�8QSS3g��u����'>@�wׄr��1p�����G9T��{G�so�����^����Di���q�SO�oEE�$a/���o����6//O��
@�s��M�0a�b��ߠ�G��wWU5��/7��e�5k����)e:�R��@��^� 		�]]]�~��e��?~��B]��G-��֩�(�|����0�J޲����fBL����!Ĺ=3s�ɢ3�'�h��K��زsg!&��)m���~x��e���vB����u�� �c�5��s�%	75�^x!@r*}玔���oOB�	LA;��
��)����__��������E`=x�]@�}���}�����׿f���9�Qѧ̜9X�#�U��}��ؠ cT�R�9!���?������uGN�8��v���Qq�A�pyy�;������0n\�<�Z@�OJ
P��~$�?�q�ܹ��:}\��6b���[����"g����8�]�]s���F�z���
��g �c`�	Mimm}��,�V�4�Pyy�֭[�F�N�T�������$y�$	WU]�����2�s���(tC�zh
�d�]?��"0l�TP^�$�/I����+++��>��
����cbbbcc�t1>��Dcc!��N;�"���PT� �l��L�HV��>�ϋ@��������)tA�{,**:t(x#�$a��n�T���:l�"
|�x;����.�^�a���߷�˒�=c�@rrrQQh��{K���Z���x��8�o�)-*�EH�_�_`��kn�	59������
q瀱�KYY%�Y���.�rSSS��v���^�:66<�tѽO?=
@E��MƲ�H���1Ƽ�M�ځ�܋

�K�m�حO?=�W111�W���6oPq풊����V{V���?�GHw�T������	Ԡ1ؼ�{�
��_�������vO��B��d���Hu�0��Y5��ر���+���$j��Lw�N�2I�������L)�c���)7��#��K˞�]����ط�@�4�o1�2}���m�NKV��n����=�%�6/�������:�Chll,..���	� '碻��'e��+??w�A�#�LU��g�ؗe&I��<��g1y��p��w�]T���`�������� �@zaa�mۼ�c���~��%��?I���
E�{aU�._��u�Ɗ�fA�I��t��(�R�ד������cS������˗.�
#��!�u����Bpc��s�


���^���^Zz����k*s��JQZć1�3��Ѐ1�����KS����]!|2��4?���e�
'���^�r�z�콼�s@75���4xs �"##/]�����1뛚�����s*�h���2�L��Y#F4$����0��f);����қ)�;hPU�<c������ED��x2�X��o�)[�&+?����cD�\TtyʔX�			�t+�jjjF��Ο�����`�c�o�9O��NG����Ç � ��7��8�o�����.�pa�ر��a���8�ʚ��e��GK�?J}�C>�
x^��l24vA�iӦEEEAW����M�8�8�"0D�#��y�E�3�!~V�}��܍��t�0?�Ib�75��!�FI>ne���	<�IT�
>\��X��ʔ)SԜw�ֶ�8_���Q֮O�c�RL��s�eZ]����H���
�@��-���-�f������]���<�N���mn�[
ԨB��6p�)����-76����.�ڥt���|B�miq�k�7���Z��Zp�:nߛ,���!��}��:�Ƃ�|�K�qY���W�A"L�3����<�C(�S��\��UE2Wl�2c�{��yG��}@KK˖-[���9E5��m�ΡbAi������m�z��
��REi��n4�##�bbB""M&=粢�pN����$~�r�ʖ-[���]�-S^��'O������y�a����G�K!Ĺ��8p��1����~����!Ĺ��s�}#�UW_}��{8���n����c~��Ĥ��@�H�
��\ٻ�����^���c��q���jmm=q�*�"�$I2���q*����M�`�(U��B^xa��7����ܭ�����矿


j�{��!`�����\�'��0}z�o;u��϶o/����p��_�:��,�꾦����Wtt��0*�E���.]��h/c�8����3mݺ��FIXI�����s�jj�B�:�b1l�v�m�%0�K~6�Xj�'��l�ӹ����z�HD�j�(4�н���ʝI��õ�-a�E�丸���2�sN�z�����Qx�r��` �?��O{l��A�z�쳷:T*���.`!!F��J{{;BH��w���{L���
m� oF�;�H�7���f��?ݳ��~���t������?nm�W�N�����VB޷8<:ڢ��꒒��q�О.����Bxڅ������h�
ƌ��Yw�@ٞ=g$)ș�0!�'��7[,=�7v'lA��w,�L����$וֹ�ujF����JJJ(�*=�:������.��}_�Ep[��ABJI�3	m��J�N�m#�5e7<��	:�C?�v	�sݧ���������G��d�s�%>~��$]��1`p��A��F�N7bޢ
�
�Z�~~~��ESqqAqqA����nU��	A�`�C����^0�. �0}�O^|q��-"���ι�M$U��KB��b���_�n݊+���=�8J�� �QZZ������=�AQY���c�&�>t���bb,����z�W���v�!J>��!Q����m�Ν<�H��z�����9���
b@L�3�o?����|�0粿�a͚�˗������<��յ`�$_x)�ӧǫH�΢���Ύ���Z����qqq�E$�2���ʢ����ބ0��h4�������=�3�8L�>���	�Uq.GEY��Y:j�@a�A���UU��ʫee�g�6��_N);r�1�E)�Ϝ9:X��r�L���������m6��b���JLL��㏟|�Iq �7b4���<%���Q��Ǎ��˻x��n��/D�І
��5�fS�F�����XN���ʫ�lP0��ȑ�>���FE�)�u�8��%((���:""b�ȑ�ϟ�x�������А��	.~�ΐ+T̔��v�J�wR�%	�sOJ^^BF����$���H?��� J�'�7/��F��}����B�q�S�`��(���"�]w
���(NJwpiJ�9s��"�rcc��l5���OLJJJNN���32����y�.��������.c�ii1�ד�j��/gH��S&�2�7�G�
D��q���q�-�����C
4h�ԩ"�'44T���.<bZǤ��?��9rd��ك�("�������"]�Q2�\�Y�Μ9��ф���o��W�VcIDk�7Hp��G<�}ƌ�q��6.x۵kWfffrrrbbbNN���8y��\Q� ��Z�c?<����	j7��s�EQZ�P-O��f�(,<�ܸ�^�Q�A�!��7��m���&�Vk�Y7""@�ǜsIRG�D�����W^��9v���n�6�;�����-v�uuuǎ[�b������
����m�6�>~������L�@0���}�T
�zO�X����=����Y`2I�w�-.��**�e����ys��X��"��s�9�\9{͚t���)���k��C��<�Xڻ��cL��#�0iR�ƍ���*�`B0�
��s��`%B�1�С������������Pq�ر�����{�y���ʘ���@PcR<���|��wwZ�9�!�txժɏ>�
!��(���,�5kȜ9	^�<��+I�������$���C���3f�ەI����Z�67/�FQXBB�/~1f޼Dظ�஻�CC��P����w���!11T��ڵ?��O��m;SWעד���R�3�`�ۍF�hD��_���Fnk������S�<��d�T5���??��W�:�yee�Y��b��F���y�z���ᄈZ�j`��E��CcRSQډ+C謄`B��*��c�֬����0$Y���];?;��#Gۼy�w$�_����+������X�0&mmm�W)�9�=4z׮%G�<�����.\�b0H��5����Bv��jUZU�3?<�F������e�ƹL��2l�0�Ѹu�ּ���FGG��ӧ)��O.I�}�ƍ���:y��m����,*�^O��or����M>t���"�X`����+
��p���Y�>��?����q΢?���/�|��7����<t��l֝:uI������s�~�n�=C�;�Qӗ/������_?��ڼaÉ��m�Z�@8\��
�9}�ř&���Wyu[[��l~�G6n�(�ONNNMMMnnnFF��`�r��	ڽ{�ɓ'�{�9�قnX�Bwݵ13�!fg����y�
��%I�>=qƌ��� ��\�ܚ�_�{���
�cη 5_��T�F�9I��11�Pm����ꬬ���+�0c�F�sO��$UUY������Z�$�c�s�|��R�l*B�����t:Y�O�:u�ԩ��z�ٜ��.�#�Nn� �ߺu�%K�&�)VW�O����Vʼn��i�V��9A��A�B����l�-n�=�qQ>�99���N��"�8��!�z'��F#��]1zt�Z
T�Fill|뭷V�XA)u?�ǂO)J�Khh�O>��-b�(lذ�W^�`s1�]O�>.�a�q�%ɟ3!&�!�:�5Ϣ�GΧL�?N��	1��#$����?�a���j�w��������ర0�Ž��M](�I߽�)�ƈN��dD���	!���~{JV�5�#�`��^�����4!��7�9r$%%����f�9����1c�,\�н�[��V��x�"�R=�t��uM�@tϱ/J�GF�殈�
C����ڽ{��9sf�С.���z+<<<00�d2�������N�G�bٜY����5  �3
���;x�œ9dY�
�gѠ���XVֲٳ���R�bee��ݻKKKǏ_QQ�`����dmm�N�ս�q�������~[�tJ�g���M��a�"��Yx�ƭt:\�ȹ����={����.TDGG�X�bŊ������hii*��.�N�ng�
		9|�pSS������3C8�`E�c�F�����=M��z��V�$	Q��?޹jU�H��4������>۱cGQQѤI��M�STT���e��cccE<V�YF�#��yu:]XXخ]�_����9F����XB��|sF��#hЁ}Ei}�y���3�{.�c��ollLOO����?iii�%??Ĉ&�	<��ݖ��p>������g�}���!�)U�������#c����>J�0Ɯ��_���?L�T�^8��;����f����,�{��IOO������;�M�Нw�y劷�@�����.=$Ĵb��1!�[R7��eJ�;�,^�r�'쫆�������^/�2�XT59q™(��{o���&�e��.�Sw��X��㏏���G�����K�p��"bY$�����t�ʉ�L]���9ϔ������hmm�ϊ��t��ӧ���.�p�6��Q�-q����$aY�s�&?��ĉ�����\��}�1!�(-c��?��]w%���	!b��;�l6�ᇢR������j���w[���2�/�.]R�d2y:�D�o�(,$Ĵl�X��dg��\!D���=G��c�9]�z�'�,8�_�<��j��6�����G��Z����#G����>x�^��$)77�����w_PP��ߎ�o$�H5�nذ�j�>���*m��eq`�8�eŊݧO�#d�Xr��!wFJ)��RRb׭���:���Pcc��)�,++�琐�/�����@�e??���{ĈZ+�M!��ЫW����qqqK�.�J��U5�ەw�9������ס�b	|���V�	�������_
�|���	!˗/�����?����tժU���v����=  @5�v��tb���aÆ�ٳ��ŋ�G���b-;FݩSc�-�?u��f� �%�`z�w��
��~~�+ӷlY<o^�(��2}��c/^������������={�,Z�(((�Rj0ƍW\\|�̙I�&B�F#r�r�=�G���'�v4<<|����~����0�u��J���(,,��/��׿N{シ����@/]�N���u�=)Nu@DĀG�bń�hc�E��*))ٹs��j�m��ũ���W5mKX��ӟ�_����.<<\(�^j�2�Ԏ��_�l�:�I��9Pk�
,DD���Ҍ5k�df��裓�����Y@ �8R��=�[p��q�P�p�)`ڴ�}��CE���9��#�����Of̘���N����f�����ÇBE��� B��n���G�S�謮\��r���q|Y=^Y��ںwoɞ=%99++��)`�C)>�5�4r0�Gl��QQAS��7/q��Ę���h�i����ƿ��/��sOZZ�6&Ş���7�|3!!���t�/����ɓ���o}���L���E(///"""::���;!)�];���]�ᇆ���￯+,����z�R���eYs&�:���8�/&�2lXXjj���QÆ
0�tZ��j��dgg8p�w���:�B---���&�)::����>PeĈ���/^|�G���!�.Лgʻi����m۶-[�,%%E]
���Y�����(�1zt8t�}��lkn�77�l6ET����(-CP��ej���ĩ�Z�|�0���MMM��������9r����f�QJ�L��x��g�y&77����!!!��{��]��W�
��⋯���;�={�ף7<�#�@D��/�����E~�,TM�P%՝���7�`�%&&���744DEEM�0aȐ!eee۷o��/~1v��.�-�C-���9sf���K�,5j������jo=UdU�w��v�}�PuuufffsssBB�ĉE4��iݺu���K�,QE����,�Ӡ���`0�t:
�Ԫ%]k�}	Zk���Ւ$��ߎ����������#ͽ�:��2�M��u���~ח�j8ڽ+w&�ɲ̝gJ�t�С���ɓ'�S8����M!��[ZN\�裏0��Q8�$КuA3��ZWW��̞=;55��ի������{�"##=���mD���S�sii�_|QQQ1v��Y�f����#���Ψ�\U���Fg`��k׮��\�ɤ(JXXXFFFll����}��U2�={vǎIII�-r��&�^����Q�-//���=ztzz��ns�ҥ�����ਨ(�9��ZފPǣVbTEQ�.+�c��TcVG�ܐճ����*��v{NNN~~~}}}BB�w��}�������#�,��6M@S�g���f[�v��b�0aBRR�8rB��hg����ӻ����)."o+11�;)�#.BŽ�(�Gq��={��ɓ'ϟ?o�Z���222z��wQ"477WVV�?>!!Aez*��B�M��[Zpwj�$IÆ
>|��(�ΝsG����4hP``��b	-�c��PJE�#u'�c�Y�	!������.=QU�>����upZNF���"I�رc��f�ɲ�r����h1����ׯ_���"����+W��a������hȐ!���Bހ�٪w��h��v��eV����V��:`�m ����B�Ӡ����X��p��2�=�-DO��w��!��G�=m�����g�n-Z�kd߲�C��W��~���R��J/<tEXtcomment Image generated by GNU Ghostscript (device=pnmraw)
���IEND�B`�PKN��\~�@�P7P7	mime.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: MIME support">
<meta name="keywords" content="Lua, LuaSocket, MIME, Library, Support"> 
<title>LuaSocket: MIME module</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- mime +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=mime>MIME</h2> 

<p>
The <tt>mime</tt> 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 
<a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>,
<a href="http://www.ietf.org/rfc/rfc2046.txt">2046</a>,
<a href="http://www.ietf.org/rfc/rfc2047.txt">2047</a>,
<a href="http://www.ietf.org/rfc/rfc2047.txt">2048</a>, and
<a href="http://www.ietf.org/rfc/rfc2048.txt">2049</a>.
</p>

<p>
All functionality provided by the MIME module 
follows the ideas presented in 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">
LTN012, Filters sources and sinks</a>. 
</p>

<p> 
To obtain the <tt>mime</tt> namespace, run:
</p>

<pre class=example>
-- loads the MIME module and everything it requires
local mime = require("mime")
</pre>


<!-- High-level +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id=high>High-level filters</h3>

<!-- normalize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="normalize">
mime.<b>normalize(</b>[marker]<b>)</b>
</p>

<p class=description>
Converts most common end-of-line markers to a specific given marker. 
</p>

<p class=parameters>
<tt>Marker</tt> is the new marker. It defaults to CRLF, the canonic 
end-of-line marker defined by the MIME standard.
</p>

<p class=return>
The function returns a filter that performs the conversion. 
</p>

<p class=note>
Note: There is no perfect solution to this problem. Different end-of-line
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), 
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 
guarantee that the number of empty lines will be correct.
</p>

<!-- decode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="decode">
mime.<b>decode(</b>"base64"<b>)</b><br>
mime.<b>decode(</b>"quoted-printable"<b>)</b>
</p>

<p class=description>
Returns a filter that decodes data from a given transfer content
encoding.
</p>

<!-- encode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="encode">
mime.<b>encode(</b>"base64"<b>)</b><br>
mime.<b>encode(</b>"quoted-printable" [, mode]<b>)</b>
</p>

<p class=description>
Returns a filter that encodes data according to a given transfer content
encoding.
</p>

<p class=parameters>
In the Quoted-Printable case, the user can specify whether the data is
textual or binary, by passing the <tt>mode</tt> strings "<tt>text</tt>" or
"<tt>binary</tt>". <tt>Mode</tt> defaults to "<tt>text</tt>".
</p>

<p class=note>
Although both transfer content encodings specify a limit for the line
length, the encoding filters do <em>not</em> break text into lines (for
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.
</p>

<pre class=example>
base64 = ltn12.filter.chain(
  mime.encode("base64"),
  mime.wrap("base64")
)
</pre>

<p class=note>
Note: Text data <em>has</em> to be converted to canonic form
<em>before</em> being encoded.
</p>

<pre class=example>
base64 = ltn12.filter.chain(
  mime.normalize(),
  mime.encode("base64"),
  mime.wrap("base64")
)
</pre>

<!-- stuff +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="stuff">
mime.<b>stuff()</b><br>
</p>

<p class=description>
Creates and returns a filter that performs stuffing of SMTP messages.
</p>

<p class=note>
Note: The <a href=smtp.html#send><tt>smtp.send</tt></a> function 
uses this filter automatically. You don't need to chain it with your
source, or apply it to your message body.  
</p>

<!-- wrap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="wrap">
mime.<b>wrap(</b>"text" [, length]<b>)</b><br>
mime.<b>wrap(</b>"base64"<b>)</b><br>
mime.<b>wrap(</b>"quoted-printable"<b>)</b>
</p>

<p class=description>
Returns a filter that breaks data into lines. 
</p>

<p class=parameters>
The "<tt>text</tt>" line-wrap filter simply breaks text into lines by 
inserting CRLF end-of-line markers at appropriate positions. 
<tt>Length</tt> defaults 76. 
The "<tt>base64</tt>" line-wrap filter works just like the default
"<tt>text</tt>" line-wrap filter with default length. 
The function can also wrap "<tt>quoted-printable</tt>" lines, taking care
not to break lines in the middle of an escaped character. In that case, the
line length is fixed at 76.
</p>

<p class=note>
For example, to create an encoding filter for the Quoted-Printable transfer content encoding of text data, do the following:
</p>

<pre class=example>
qp = ltn12.filter.chain(
  mime.normalize(),
  mime.encode("quoted-printable"),
  mime.wrap("quoted-printable")
)
</pre>

<p class=note>
Note: To break into lines with a different end-of-line convention, apply
a normalization filter after the line break filter. 
</p>

<!-- Low-level ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id=low>Low-level filters</h3>

<!-- b64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="b64">
A, B = mime.<b>b64(</b>C [, D]<b>)</b>
</p>

<p class=description>
Low-level filter to perform Base64 encoding. 
</p>

<p class=description>
<tt>A</tt> is the encoded version of the largest prefix of 
<tt>C..D</tt> 
that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of 
<tt>C..D</tt>, <em>before</em> encoding. 
If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with 
the encoding of the remaining bytes of <tt>C</tt>. 
</p>

<p class=note>
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 <tt>mime.b64</tt>, to discard the second return value.
</p>

<pre class=example>
print((mime.b64("diego:password")))
--&gt; ZGllZ286cGFzc3dvcmQ=
</pre>

<!-- dot +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id="dot">
A, n = mime.<b>dot(</b>m [, B]<b>)</b>
</p>

<p class=description>
Low-level filter to perform SMTP stuffing and enable transmission of
messages containing the sequence "CRLF.CRLF". 
</p>

<p class=parameters>
<tt>A</tt> is the stuffed version of <tt>B</tt>. '<tt>n</tt>' gives the
number of characters from the sequence CRLF seen in the end of <tt>B</tt>.
'<tt>m</tt>' should tell the same, but for the previous chunk.
</p>

<p class=note>Note: The message body is defined to begin with 
an implicit CRLF. Therefore, to stuff a message correctly, the
first <tt>m</tt> should have the value 2. 
</p>

<pre class=example>
print((string.gsub(mime.dot(2, ".\r\nStuffing the message.\r\n.\r\n."), "\r\n", "\\n")))
--&gt; ..\nStuffing the message.\n..\n..
</pre>

<p class=note>
Note: The <a href=smtp.html#send><tt>smtp.send</tt></a> function 
uses this filter automatically. You don't need to 
apply it again. 
</p>

<!-- eol ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="eol">
A, B = mime.<b>eol(</b>C [, D, marker]<b>)</b>
</p>

<p class=description>
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. 
</p>

<p class=parameters>
<tt>A</tt> is the translated version of <tt>D</tt>. <tt>C</tt> is the
ASCII value of the last character of the previous chunk, if it was a
candidate for line break, or 0 otherwise. 
<tt>B</tt> is the same as <tt>C</tt>, but for the current
chunk. <tt>Marker</tt> gives the new end-of-line marker and defaults to CRLF.
</p>

<pre class=example>
-- translates the end-of-line marker to UNIX
unix = mime.eol(0, dos, "\n") 
</pre>

<!-- qp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="qp">
A, B = mime.<b>qp(</b>C [, D, marker]<b>)</b>
</p>

<p class=description>
Low-level filter to perform Quoted-Printable encoding. 
</p>

<p class=parameters>
<tt>A</tt> is the encoded version of the largest prefix of 
<tt>C..D</tt> 
that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of 
<tt>C..D</tt>, <em>before</em> encoding. 
If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with 
the encoding of the remaining bytes of <tt>C</tt>. 
Throughout encoding, occurrences of CRLF are replaced by the 
<tt>marker</tt>, which itself defaults to CRLF.
</p>

<p class=note>
Note: The simplest use of this function is to encode a string into it's
Quoted-Printable transfer content encoding. 
Notice the extra parenthesis around the call to <tt>mime.qp</tt>, to discard the second return value.
</p>

<pre class=example>
print((mime.qp("ma��")))
--&gt; ma=E7=E3=
</pre>

<!-- qpwrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="qpwrp">
A, m = mime.<b>qpwrp(</b>n [, B, length]<b>)</b>
</p>

<p class=description>
Low-level filter to break Quoted-Printable text into lines. 
</p>

<p class=parameters>
<tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most 
<tt>length</tt> bytes (defaults to 76). 
'<tt>n</tt>' should tell how many bytes are left for the first 
line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes 
left in the last line of <tt>A</tt>. 
</p>

<p class=note>
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 <tt>length</tt> bytes.
</p>

<!-- unb64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="unb64">
A, B = mime.<b>unb64(</b>C [, D]<b>)</b>
</p>

<p class=description>
Low-level filter to perform Base64 decoding. 
</p>

<p class=parameters>
<tt>A</tt> is the decoded version of the largest prefix of 
<tt>C..D</tt> 
that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of 
<tt>C..D</tt>, <em>before</em> decoding. 
If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is the empty string
and <tt>B</tt> returns whatever couldn't be decoded. 
</p>

<p class=note>
Note: The simplest use of this function is to decode a string from it's
Base64 transfer content encoding. 
Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value.
</p>

<pre class=example>
print((mime.unb64("ZGllZ286cGFzc3dvcmQ=")))
--&gt; diego:password
</pre>

<!-- unqp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="unqp">
A, B = mime.<b>unqp(</b>C [, D]<b>)</b>
</p>

<p class=description>
Low-level filter to remove the Quoted-Printable transfer content encoding
from data. 
</p>

<p class=parameters>
<tt>A</tt> is the decoded version of the largest prefix of 
<tt>C..D</tt> 
that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of 
<tt>C..D</tt>, <em>before</em> decoding. 
If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is augmented with 
the encoding of the remaining bytes of <tt>C</tt>. 
</p>

<p class=note>
Note: The simplest use of this function is to decode a string from it's
Quoted-Printable transfer content encoding. 
Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value.
</p>

<pre class=example>
print((mime.qp("ma=E7=E3=")))
--&gt; ma��
</pre>

<!-- wrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="wrp">
A, m = mime.<b>wrp(</b>n [, B, length]<b>)</b>
</p>

<p class=description>
Low-level filter to break text into lines with CRLF marker. 
Text is assumed to be in the <a href=#normalize><tt>normalize</tt></a> form.
</p>

<p class=parameters>
<tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most 
<tt>length</tt> bytes (defaults to 76). 
'<tt>n</tt>' should tell how many bytes are left for the first 
line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes 
left in the last line of <tt>A</tt>. 
</p>

<p class=note>
Note: This function only breaks lines that are bigger than 
<tt>length</tt> bytes. The resulting line length does not include the CRLF
marker.
</p>


<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:44 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\޶j���
reference.cssnu�[���body { 
    margin-left: 1em; 
    margin-right: 1em; 
    font-family: "Verdana", sans-serif; 
}

tt {
    font-family: "Andale Mono", monospace; 
}

h1, h2, h3, h4 { margin-left: 0em; }


h3 { padding-top: 1em; }

p { margin-left: 1em; }

p.name { 
    font-family: "Andale Mono", monospace; 
    padding-top: 1em;
    margin-left: 0em; 
}

a[href] { color: #00007f; }

blockquote { margin-left: 3em; }

pre.example {
    background: #ccc;
    padding: 1em;
    margin-left: 1em;
    font-family: "Andale Mono", monospace; 
    font-size: small;
}

hr { 
    margin-left: 0em;
	background: #00007f; 
	border: 0px;
	height: 1px;
}

ul { list-style-type: disc; }

table.index { border: 1px #00007f; }
table.index td { text-align: left; vertical-align: top; }
table.index ul { padding-top: 0em; margin-top: 0em; }

h1:first-letter, 
h2:first-letter, 
h2:first-letter, 
h3:first-letter { color: #00007f; }

div.header, div.footer { margin-left: 0em; }
PKN��\�ߝ��reference.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: Index to reference manual">
<meta name="keywords" content="Lua, LuaSocket, Index, Manual, Network, Library,
Support, Manual"> 
<title>LuaSocket: Index to reference manual</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- reference +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2>Reference</h2>

<blockquote>
<a href="dns.html">DNS (in socket)</a>
<blockquote>
<a href="dns.html#getaddrinfo">getaddrinfo</a>,
<a href="dns.html#gethostname">gethostname</a>,
<a href="dns.html#tohostname">tohostname</a>,
<a href="dns.html#toip">toip</a>.
</blockquote>
</blockquote>

<!-- ftp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<blockquote>
<a href="ftp.html">FTP</a>
<blockquote>
<a href="ftp.html#get">get</a>,
<a href="ftp.html#put">put</a>.
</blockquote>
</blockquote>

<!-- http +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<blockquote>
<a href="http.html">HTTP</a>
<blockquote>
<a href="http.html#request">request</a>.
</blockquote>
</blockquote>

<!-- ltn12 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<blockquote>
<a href="ltn12.html">LTN12</a>
<blockquote>
<a href="ltn12.html#filter">filter</a>:
<a href="ltn12.html#filter.chain">chain</a>,
<a href="ltn12.html#filter.cycle">cycle</a>.
</blockquote>
<blockquote>
<a href="ltn12.html#pump">pump</a>:
<a href="ltn12.html#pump.all">all</a>,
<a href="ltn12.html#pump.step">step</a>.
</blockquote>
<blockquote>
<a href="ltn12.html#sink">sink</a>:
<a href="ltn12.html#sink.chain">chain</a>,
<a href="ltn12.html#sink.error">error</a>,
<a href="ltn12.html#sink.file">file</a>,
<a href="ltn12.html#sink.null">null</a>,
<a href="ltn12.html#sink.simplify">simplify</a>,
<a href="ltn12.html#sink.table">table</a>.
</blockquote>
<blockquote>
<a href="ltn12.html#source">source</a>: 
<a href="ltn12.html#source.cat">cat</a>,
<a href="ltn12.html#source.chain">chain</a>,
<a href="ltn12.html#source.empty">empty</a>,
<a href="ltn12.html#source.error">error</a>,
<a href="ltn12.html#source.file">file</a>,
<a href="ltn12.html#source.simplify">simplify</a>,
<a href="ltn12.html#source.string">string</a>.
</blockquote>
</blockquote>

<!-- mime +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<blockquote>
<a href="mime.html">MIME</a>
<blockquote>
<a href="mime.html#high">high-level</a>:
<a href="mime.html#decode">decode</a>,
<a href="mime.html#encode">encode</a>,
<a href="mime.html#normalize">normalize</a>,
<a href="mime.html#stuff">stuff</a>,
<a href="mime.html#wrap">wrap</a>.
</blockquote>
<blockquote>
<a href="mime.html#low">low-level</a>:
<a href="mime.html#b64">b64</a>,
<a href="mime.html#dot">dot</a>,
<a href="mime.html#eol">eol</a>,
<a href="mime.html#qp">qp</a>,
<a href="mime.html#qpwrp">qpwrp</a>,
<a href="mime.html#unb64">unb64</a>,
<a href="mime.html#unqp">unqp</a>,
<a href="mime.html#wrp">wrp</a>.
</blockquote>
</blockquote>

<!-- smtp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<blockquote>
<a href="smtp.html">SMTP</a>
<blockquote>
<a href="smtp.html#message">message</a>,
<a href="smtp.html#send">send</a>.
</blockquote>
</blockquote>

<!-- socket +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<blockquote>
<a href="socket.html">Socket</a>
<blockquote>
<a href="socket.html#bind">bind</a>,
<a href="socket.html#connect">connect</a>,
<a href="socket.html#connect">connect4</a>,
<a href="socket.html#connect">connect6</a>,
<a href="socket.html#debug">_DEBUG</a>,
<a href="dns.html#dns">dns</a>,
<a href="socket.html#gettime">gettime</a>,
<a href="socket.html#headers.canonic">headers.canonic</a>,
<a href="socket.html#newtry">newtry</a>,
<a href="socket.html#protect">protect</a>,
<a href="socket.html#select">select</a>,
<a href="socket.html#sink">sink</a>,
<a href="socket.html#skip">skip</a>,
<a href="socket.html#sleep">sleep</a>,
<a href="socket.html#setsize">_SETSIZE</a>,
<a href="socket.html#source">source</a>,
<a href="tcp.html#socket.tcp">tcp</a>,
<a href="tcp.html#socket.tcp6">tcp6</a>,
<a href="socket.html#try">try</a>,
<a href="udp.html#socket.udp">udp</a>,
<a href="udp.html#socket.udp6">udp6</a>,
<a href="socket.html#version">_VERSION</a>.
</blockquote>
</blockquote>

<!-- tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<blockquote>
<a href="tcp.html">TCP (in socket)</a>
<blockquote>
<a href="tcp.html#accept">accept</a>,
<a href="tcp.html#bind">bind</a>,
<a href="tcp.html#close">close</a>,
<a href="tcp.html#connect">connect</a>,
<a href="tcp.html#dirty">dirty</a>,
<a href="tcp.html#getfd">getfd</a>,
<a href="tcp.html#getoption">getoption</a>,
<a href="tcp.html#getpeername">getpeername</a>,
<a href="tcp.html#getsockname">getsockname</a>,
<a href="tcp.html#getstats">getstats</a>,
<a href="tcp.html#listen">listen</a>,
<a href="tcp.html#receive">receive</a>,
<a href="tcp.html#send">send</a>,
<a href="tcp.html#setfd">setfd</a>,
<a href="tcp.html#setoption">setoption</a>,
<a href="tcp.html#setstats">setstats</a>,
<a href="tcp.html#settimeout">settimeout</a>,
<a href="tcp.html#shutdown">shutdown</a>.
</blockquote>
</blockquote>

<!-- udp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<blockquote>
<a href="udp.html">UDP (in socket)</a>
<blockquote>
<a href="udp.html#close">close</a>,
<a href="udp.html#getoption">getoption</a>,
<a href="udp.html#getpeername">getpeername</a>,
<a href="udp.html#getsockname">getsockname</a>,
<a href="udp.html#receive">receive</a>,
<a href="udp.html#receivefrom">receivefrom</a>,
<a href="udp.html#send">send</a>,
<a href="udp.html#sendto">sendto</a>,
<a href="udp.html#setpeername">setpeername</a>,
<a href="udp.html#setsockname">setsockname</a>,
<a href="udp.html#setoption">setoption</a>,
<a href="udp.html#settimeout">settimeout</a>.
</blockquote>
</blockquote>

<!-- url ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<blockquote>
<a href="url.html">URL</a>
<blockquote>
<a href="url.html#absolute">absolute</a>,
<a href="url.html#build">build</a>,
<a href="url.html#build_path">build_path</a>,
<a href="url.html#escape">escape</a>,
<a href="url.html#parse">parse</a>,
<a href="url.html#parse_path">parse_path</a>,
<a href="url.html#unescape">unescape</a>.
</blockquote>
</blockquote>

<!-- footer ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:47 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\e�f��8�8	smtp.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: SMTP support">
<meta name="keywords" content="Lua, LuaSocket, SMTP, E-Mail, MIME, Multipart,
Library, Support"> 
<title>LuaSocket: SMTP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- smtp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=smtp>SMTP</h2> 

<p> The  <tt>smtp</tt> namespace provides functionality to send e-mail
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).  
</p>

<p>The implementation conforms to the Simple Mail Transfer Protocol,
<a href="http://www.ietf.org/rfc/rfc2821.txt">RFC 2821</a>.
Another RFC of interest is <a
href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>,
which governs the Internet Message Format.
Multipart messages (those that contain attachments) are part
of the MIME standard, but described mainly
in <a href="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</a>

<p> In the description below, good understanding of <a
href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> LTN012, Filters
sources and sinks</a> and the  <a href=mime.html>MIME</a> module is
assumed.  In fact, the SMTP module was the main reason for their 
creation. </p>

<p> 
To obtain the <tt>smtp</tt> namespace, run:
</p>

<pre class=example>
-- loads the SMTP module and everything it requires
local smtp = require("socket.smtp")
</pre>

<p>
MIME headers are represented as a Lua table in the form:
</p>

<blockquote>
<table summary="MIME headers in Lua table">
<tr><td><tt>
headers = {<br>
&nbsp;&nbsp;field-1-name = <i>field-1-value</i>,<br>
&nbsp;&nbsp;field-2-name = <i>field-2-value</i>,<br>
&nbsp;&nbsp;field-3-name = <i>field-3-value</i>,<br>
&nbsp;&nbsp;...<br>
&nbsp;&nbsp;field-n-name = <i>field-n-value</i><br>
}
</tt></td></tr>
</table>
</blockquote>

<p>
Field names are case insensitive (as specified by the standard) and all
functions work with lowercase field names (but see
<a href=socket.html#headers.canonic><tt>socket.headers.canonic</tt></a>).
Field values are left unmodified.
</p>

<p class=note>
Note: MIME headers are independent of order. Therefore, there is no problem
in representing them in a Lua table. 
</p>

<p>
The following constants can be set to control the default behavior of
the SMTP module: 
</p>

<ul>
<li> <tt>DOMAIN</tt>: domain used to greet the server;
<li> <tt>PORT</tt>: default port used for the connection;
<li> <tt>SERVER</tt>: default server used for the connection;
<li> <tt>TIMEOUT</tt>: default timeout for all I/O operations;
<li> <tt>ZONE</tt>: default time zone.
</ul>

<!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=send> 
smtp.<b>send{</b><br>
&nbsp;&nbsp;from = <i>string</i>,<br>
&nbsp;&nbsp;rcpt = <i>string</i> or <i>string-table</i>,<br>
&nbsp;&nbsp;source = <i>LTN12 source</i>,<br>
&nbsp;&nbsp;[user = <i>string</i>,]<br>
&nbsp;&nbsp;[password = <i>string</i>,]<br>
&nbsp;&nbsp;[server = <i>string</i>,]<br>
&nbsp;&nbsp;[port = <i>number</i>,]<br>
&nbsp;&nbsp;[domain = <i>string</i>,]<br>
&nbsp;&nbsp;[step = <i>LTN12 pump step</i>,]<br>
&nbsp;&nbsp;[create = <i>function</i>]<br>
<b>}</b>
</p>

<p class=description>
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 
<a href=#message><tt>message</tt></a> source factory for 
a very powerful way to define the message contents.
</p>


<p class=parameters>
The sender is given by the e-mail address in the <tt>from</tt> field. 
<tt>Rcpt</tt> 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 <em>simple</em> 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
<tt>source</tt>. Several arguments are optional:
</p>
<ul>
<li> <tt>user</tt>, <tt>password</tt>: User and password for
authentication. The function will attempt LOGIN and PLAIN authentication
methods if supported by the server (both are unsafe);
<li> <tt>server</tt>: Server to connect to. Defaults to "localhost";
<li> <tt>port</tt>: Port to connect to. Defaults to 25;
<li> <tt>domain</tt>: Domain name used to greet the server; Defaults to the
local machine host name; 
<li> <tt>step</tt>: 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
pump step function used to pass data from the
source to the server. Defaults to the LTN12 <tt>pump.step</tt> function;
<li><tt>create</tt>: An optional function to be used instead of
<a href=tcp.html#socket.tcp><tt>socket.tcp</tt></a> when the communications socket is created. 
</ul>

<p class=return> 
If  successful, the function returns 1. Otherwise, the function returns
<b><tt>nil</tt></b> followed by an error message.
</p>

<p class=note>
Note: SMTP servers can be very picky with the format of e-mail
addresses. To be safe, use only addresses of the form
"<tt>&lt;fulano@example.com&gt;</tt>" in the <tt>from</tt> and
<tt>rcpt</tt> arguments to the <tt>send</tt> function. In headers, e-mail
addresses can take whatever form you like.  </p>

<p class=note>
Big note: There is a good deal of misconception with the use of the
destination address field headers, i.e., the '<tt>To</tt>', '<tt>Cc</tt>',
and, more importantly, the '<tt>Bcc</tt>' headers. Do <em>not</em> add a
'<tt>Bcc</tt>' header to your messages because it will probably do the
exact opposite of what you expect.
</p>

<p class=note>
Only recipients specified in the <tt>rcpt</tt> 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
<em>are</em> part of the message and should be produced by the 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
<tt>source</tt> function. The <tt>rcpt</tt> list is <em>not</em>
part of the message and will not be sent to anyone.
</p>

<p class=note>
<a href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>
has two <em>important and short</em> sections, "3.6.3. Destination address
fields" and "5. Security considerations",  explaining the proper
use of these headers. Here is a summary of what it says: 
</p>

<ul>
<li> <tt>To</tt>: contains the address(es) of the primary recipient(s)
of the message;
<li> <tt>Cc</tt>: (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;
<li> <tt>Bcc</tt>: (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.
</ul> 

<p class=note>
The LuaSocket <tt>send</tt> 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:
</p>
<ul>
<li> If someone is to receive the message, the e-mail address <em>has</em>
to be in the recipient list. This is the only parameter that controls who
gets a copy of the message;
<li> 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 <tt>Bcc</tt> field of popular e-mail clients; 
<li> It is up to you to add the <tt>To</tt> header with the list of primary
recipients so that other recipients can see it;
<li> It is also up to you to add the <tt>Cc</tt> header with the 
list of additional recipients so that everyone else sees it;
<li> Adding a header <tt>Bcc</tt> is nonsense, unless it is 
empty. Otherwise, everyone receiving the message will see it and that is
exactly what you <em>don't</em> want to happen!
</ul>

<p class=note>
I hope this clarifies the issue. Otherwise, please refer to 
<a href="http://www.ietf.org/rfc/rfc2821.txt">RFC 2821</a>
and
<a href="http://www.ietf.org/rfc/rfc2822.txt">RFC 2822</a>.
</p>

<pre class=example>
-- 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", 
-- 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
-- carbon copy of the message.
from = "&lt;luasocket@example.com&gt;"

rcpt = {
  "&lt;fulano@example.com&gt;",
  "&lt;beltrano@example.com&gt;",
  "&lt;sicrano@example.com&gt;"
}

mesgt = {
  headers = {
    to = "Fulano da Silva &lt;fulano@example.com&gt;",
    cc = '"Beltrano F. Nunes" &lt;beltrano@example.com&gt;',
    subject = "My first message"
  },
  body = "I hope this works. If it does, I can send you another 1000 copies."
}

r, e = smtp.send{
  from = from,
  rcpt = rcpt, 
  source = smtp.message(mesgt)
}
</pre>

<!-- message ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=message> 
smtp.<b>message(</b>mesgt<b>)</b>
</p>

<p class=description>
Returns a <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> source that sends an SMTP message body, possibly multipart (arbitrarily deep). 
</p>

<p class=parameters>
The only parameter of the function is a table describing the message.
<tt>Mesgt</tt> has the following form (notice the recursive structure):
</p>

<blockquote>
<table summary="Mesgt table structure">
<tr><td><tt>
mesgt = {<br>
&nbsp;&nbsp;headers = <i>header-table</i>,<br>
&nbsp;&nbsp;body = <i>LTN12 source</i> or <i>string</i> or 
<i>multipart-mesgt</i><br>
}<br>
&nbsp;<br>
multipart-mesgt = {<br>
&nbsp;&nbsp;[preamble = <i>string</i>,]<br>
&nbsp;&nbsp;[1] = <i>mesgt</i>,<br>
&nbsp;&nbsp;[2] = <i>mesgt</i>,<br>
&nbsp;&nbsp;...<br>
&nbsp;&nbsp;[<i>n</i>] = <i>mesgt</i>,<br>
&nbsp;&nbsp;[epilogue = <i>string</i>,]<br>
}<br>
</tt></td></tr>
</table>
</blockquote>

<p class=parameters>
For a simple message, all that is needed is a set of <tt>headers</tt>
and the <tt>body</tt>. The message <tt>body</tt> can be given as a string
or as a <em>simple</em> 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
source. For multipart messages, the body is a table that
recursively defines each part as an independent message, plus an optional
<tt>preamble</tt> and <tt>epilogue</tt>.
</p>

<p class=return> 
The function returns a <em>simple</em> 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> 
source that produces the
message contents as defined by <tt>mesgt</tt>, chunk by chunk. 
Hopefully, the following
example will make things clear. When in doubt, refer to the appropriate RFC
as listed in the introduction.  </p>

<pre class=example>
-- 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 
-- plain text, the second part is a PNG image, encoded as base64.
source = smtp.message{
  headers = {
     -- Remember that headers are *ignored* by smtp.send. 
     from = "Sicrano de Oliveira &lt;sicrano@example.com&gt;",
     to = "Fulano da Silva &lt;fulano@example.com&gt;",
     subject = "Here is a message with attachments"
  },
  body = {
    preamble = "If your client doesn't understand attachments, \r\n" ..
               "it will still display the preamble and the epilogue.\r\n" ..
               "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] = { 
      body = mime.eol(0, [[
        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, 
    -- 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 
    -- translation happens on the fly.
    [2] = { 
      headers = {
        ["content-type"] = 'image/png; name="image.png"',
        ["content-disposition"] = 'attachment; filename="image.png"',
        ["content-description"] = 'a beautiful image',
        ["content-transfer-encoding"] = "BASE64"
      },
      body = ltn12.source.chain(
        ltn12.source.file(io.open("image.png", "rb")),
        ltn12.filter.chain(
          mime.encode("base64"),
          mime.wrap()
        )
      )
    },
    epilogue = "This might also show up, but after the attachments"
  }
}

-- finally send it
r, e = smtp.send{
    from = "&lt;sicrano@example.com&gt;",
    rcpt = "&lt;fulano@example.com&gt;",
    source = source,
}
</pre>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:51 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\���*6*6socket.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: The core namespace">
<meta name="keywords" content="Lua, LuaSocket, Socket, Network, Library, Support"> 
<title>LuaSocket: The socket namespace</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- socket +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id=socket>The socket namespace</h2> 

<p>
The <tt>socket</tt> namespace contains the core functionality of LuaSocket. 
</p>

<p> 
To obtain the <tt>socket</tt> namespace, run:
</p>

<pre class=example>
-- loads the socket module 
local socket = require("socket")
</pre>

<!-- bind ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=bind> 
socket.<b>bind(</b>address, port [, backlog]<b>)</b>
</p>

<p class=description>
This function is a shortcut that creates and returns a TCP server object
bound to a local <tt>address</tt> and <tt>port</tt>, ready to 
accept client connections. Optionally,
user can also specify the <tt>backlog</tt> argument to the 
<a href=tcp.html#listen><tt>listen</tt></a> method (defaults to 32). 
</p>

<p class=note>
Note: The server object returned will have the option "<tt>reuseaddr</tt>" 
set to <tt><b>true</b></tt>.
</p>

<!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=connect> 
socket.<b>connect[46](</b>address, port [, locaddr] [, locport] [, family]<b>)</b>
</p>

<p class=description>
This function is a shortcut that creates and returns a TCP client object
connected to a remote <tt>address</tt> at a given <tt>port</tt>. Optionally,
the user can also specify the local address and port to bind
(<tt>locaddr</tt> and <tt>locport</tt>), or restrict the socket family
to "<tt>inet</tt>" or "<tt>inet6</tt>".
Without specifying <tt>family</tt> to <tt>connect</tt>, whether a tcp or tcp6
connection is created depends on your system configuration. Two variations
of connect are defined as simple helper functions that restrict the
<tt>family</tt>, <tt>socket.connect4</tt> and <tt>socket.connect6</tt>.
</p>

<!-- debug ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=debug> 
socket.<b>_DEBUG</b>
</p>

<p class=description>
This constant is set to <tt><b>true</b></tt> if the library was compiled
with debug support.
</p>

<!-- get time +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=gettime> 
socket.<b>gettime()</b>
</p>

<p class=description>
Returns the time in seconds, relative to the origin of the 
universe. You should subtract the values returned by this function
to get meaningful values. 
</p>

<pre class=example>
t = socket.gettime()
-- do stuff
print(socket.gettime() - t .. " seconds elapsed")
</pre>

<!-- socket.headers ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="headers.canonic">
socket.headers.<b>canonic</b></p>

<p> The <tt>socket.headers.canonic</tt> table 
is used by the HTTP and SMTP modules to translate from 
lowercase field names back into their canonic 
capitalization. When a lowercase field name exists as a key
in this table, the associated value is substituted in
whenever the field name is sent out.
</p>

<p> 
You can obtain the <tt>headers</tt> namespace if case run-time
modifications are required by running:
</p>

<pre class=example>
-- loads the headers module 
local headers = require("headers")
</pre>

<!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=newtry> 
socket.<b>newtry(</b>finalizer<b>)</b>
</p>

<p class=description>
Creates and returns a <em>clean</em> 
<a href="#try"><tt>try</tt></a>
function that allows for cleanup before the exception 
is  raised. 
</p>

<p class=parameters> 
<tt>Finalizer</tt> is a function that will be called before
<tt>try</tt> throws the exception. It will be called 
in <em>protected</em> mode.
</p>

<p class=return> 
The function returns your customized <tt>try</tt> function. 
</p>

<p class=note>
Note: This idea saved a <em>lot</em> of work with the 
implementation of protocols in LuaSocket: 
</p>

<pre class=example>
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 
    try(c:send("hello there?\r\n"))
    local answer = try(c:receive())
    ...
    try(c:send("good bye\r\n"))
    c:close()
end)
</pre>


<!-- protect +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=protect> 
socket.<b>protect(</b>func<b>)</b>
</p>

<p class=description>
Converts a function that throws exceptions into a safe function. This
function only catches exceptions thrown by the <a href=#try><tt>try</tt></a>
and <a href=#newtry><tt>newtry</tt></a> functions. It does not catch normal 
Lua errors.
</p>

<p class=parameters>
<tt>Func</tt> is a function that calls 
<a href=#try><tt>try</tt></a> (or <tt>assert</tt>, or <tt>error</tt>) 
to throw exceptions. 
</p>

<p class=return>
Returns an equivalent function that instead of throwing exceptions,
returns <tt><b>nil</b></tt> followed by an error message. 
</p>

<p class=note>
Note: Beware that if your function performs some illegal operation that
raises an error, the protected function will catch the error and return it
as a string. This is because the <a href=#try><tt>try</tt></a> function
uses errors as the mechanism to throw exceptions.  
</p>

<!-- select +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=select> 
socket.<b>select(</b>recvt, sendt [, timeout]<b>)</b>
</p>

<p class=description>
Waits for a number of sockets to change status. 
</p>

<p class=parameters>
<tt>Recvt</tt> is an array with the sockets to test for characters
available for reading. Sockets in the <tt>sendt</tt> array are watched to
see if it is OK to immediately write on them.  <tt>Timeout</tt> is the
maximum amount of time (in seconds) to wait for a change in status.  A
<tt><b>nil</b></tt>, negative or omitted <tt>timeout</tt> value allows the
function to block indefinitely. <tt>Recvt</tt> and <tt>sendt</tt> can also
be empty tables or <tt><b>nil</b></tt>. Non-socket values (or values with
non-numeric indices) in the arrays will be silently ignored.
</p>

<p class=return> 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 "<tt>timeout</tt>" if a timeout condition was met and
<tt><b>nil</b></tt> 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. 
</p>

<p class=note>
<b>Note: </b>: <tt>select</tt> can monitor a limited number
of sockets, as defined by the constant <tt>socket._SETSIZE</tt>. This
number may be as high as 1024 or as low as 64 by default,
depending on the system. It is usually possible to change this
at compile time. Invoking <tt>select</tt> with a larger
number of sockets will raise an error.
</p>

<p class=note>
<b>Important note</b>: a known bug in WinSock causes <tt>select</tt> to fail 
on non-blocking TCP sockets. The function may return a socket as
writable even though the socket is <em>not</em> ready for sending.
</p>

<p class=note>
<b>Another important note</b>: calling select with a server socket in the receive parameter before a call to accept does <em>not</em> guarantee
<a href=tcp.html#accept><tt>accept</tt></a> will return immediately. 
Use the <a href=tcp.html#settimeout><tt>settimeout</tt></a> 
method or <tt>accept</tt> might block forever.  
</p>

<p class=note>
<b>Yet another note</b>: If you close a socket and pass
it to <tt>select</tt>, it will be ignored.
</p>

<p class=note>
<b>Using select with non-socket objects</b>: Any object that implements <tt>getfd</tt> and <tt>dirty</tt> can be used with <tt>select</tt>, allowing objects from other libraries to be used within a <tt>socket.select</tt> driven loop.
</p>

<!-- sink ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=sink> 
socket.<b>sink(</b>mode, socket<b>)</b>
</p>

<p class=description>
Creates an 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
sink from a stream socket object. 
</p>

<p class=parameters>
<tt>Mode</tt> defines the behavior of the sink. The following
options are available:
</p>
<ul>
<li> <tt>"http-chunked"</tt>: sends data through socket after applying the
<em>chunked transfer coding</em>, closing the socket when done;
<li> <tt>"close-when-done"</tt>: sends all received data through the
socket, closing the socket when done; 
<li> <tt>"keep-open"</tt>: sends all received data through the
socket, leaving it open when done. 
</ul>
<p>
<tt>Socket</tt> is the stream socket object used to send the data. 
</p>

<p class=return>
The function returns a sink with the appropriate behavior. 
</p>

<!-- skip ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=skip> 
socket.<b>skip(</b>d [, ret<sub>1</sub>, ret<sub>2</sub> ...  ret<sub>N</sub>]<b>)</b>
</p>

<p class=description>
Drops a number of arguments and returns the remaining.
</p>

<p class=parameters>
<tt>D</tt> is the number of arguments to drop. <tt>Ret<sub>1</sub></tt> to
<tt>ret<sub>N</sub></tt> are the arguments.
</p>

<p class=return> 
The function returns <tt>ret<sub>d+1</sub></tt> to <tt>ret<sub>N</sub></tt>.
</p>

<p class=note>
Note: This function is useful to avoid creation of dummy variables:
</p>

<pre class=example>
-- get the status code and separator from SMTP server reply 
local code, sep = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"))
</pre>

<!-- sleep ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=sleep> 
socket.<b>sleep(</b>time<b>)</b>
</p>

<p class=description>
Freezes the program execution during a given amount of time.
</p>

<p class=parameters> 
<tt>Time</tt> is the number of seconds to sleep for. If
<tt>time</tt> is negative, the function returns immediately.
</p>

<!-- source +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=source> 
socket.<b>source(</b>mode, socket [, length]<b>)</b>
</p>

<p class=description>
Creates an 
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
source from a stream socket object. 
</p>

<p class=parameters>
<tt>Mode</tt> defines the behavior of the source. The following
options are available:
</p>
<ul>
<li> <tt>"http-chunked"</tt>: receives data from socket and removes the
<em>chunked transfer coding</em> before returning the data;
<li> <tt>"by-length"</tt>: receives a fixed number of bytes from the
socket. This mode requires the extra argument <tt>length</tt>; 
<li> <tt>"until-closed"</tt>: receives data from a socket until the other
side closes the connection. 
</ul>
<p>
<tt>Socket</tt> is the stream socket object used to receive the data. 
</p>

<p class=return>
The function returns a source with the appropriate behavior. 
</p>

<!-- setsize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=setsize> 
socket.<b>_SETSIZE</b>
</p>

<p class=description>
The maximum number of sockets that the <a
href=#select><tt>select</tt></a> function can handle. 
</p>

<!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=try> 
socket.<b>try(</b>ret<sub>1</sub> [, ret<sub>2</sub> ... ret<sub>N</sub>]<b>)</b>
</p>

<p class=description>
Throws an exception in case of error. The exception can only be caught 
by the <a href=#protect><tt>protect</tt></a> function. It does not explode
into an error message.
</p>

<p class=parameters>
<tt>Ret<sub>1</sub></tt> to <tt>ret<sub>N</sub></tt> can be arbitrary
arguments, but are usually the return values of a function call 
nested with <tt>try</tt>. 
</p>

<p class=return> 
The function returns <tt>ret</tt><sub>1</sub> to <tt>ret</tt><sub>N</sub> if
<tt>ret</tt><sub>1</sub> is not <tt><b>nil</b></tt>. Otherwise, it calls <tt>error</tt> passing <tt>ret</tt><sub>2</sub>.
</p>

<pre class=example>
-- connects or throws an exception with the appropriate error message
c = socket.try(socket.connect("localhost", 80))
</pre>

<!-- version ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id=version> 
socket.<b>_VERSION</b>
</p>

<p class=description>
This constant has a string describing the current LuaSocket version. 
</p>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:54 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\�4���S�Stcp.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: The TCP/IP support">
<meta name="keywords" content="Lua, LuaSocket, Socket, TCP, Library, Network, Support"> 
<title>LuaSocket: TCP/IP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id="tcp">TCP</h2> 

<!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="socket.tcp"> 
socket.<b>tcp()</b>
</p>

<p class=description> 
Creates and returns an IPv4 TCP master object. A master object can
be transformed into a server object with the method 
<a href=#listen><tt>listen</tt></a> (after a call to <a
href=#bind><tt>bind</tt></a>) or into a client object with 
the method <a href=#connect><tt>connect</tt></a>. The only other 
method supported by a master object is the 
<a href=#close><tt>close</tt></a> method.</p>

<p class=return>
In case of success, a new master object is returned. In case of error,
<b><tt>nil</tt></b> is returned, followed by an error message.
</p>

<!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="socket.tcp6"> 
socket.<b>tcp6()</b>
</p>

<p class=description> 
Creates and returns an IPv6 TCP master object. A master object can
be transformed into a server object with the method 
<a href=#listen><tt>listen</tt></a> (after a call to <a
href=#bind><tt>bind</tt></a>) or into a client object with 
the method <a href=#connect><tt>connect</tt></a>. The only other 
method supported by a master object is the 
<a href=#close><tt>close</tt></a> method.</p>

<p class=return>
In case of success, a new master object is returned. In case of error,
<b><tt>nil</tt></b> is returned, followed by an error message.
</p>

<p class=note>
Note: The TCP object returned will have the option
"<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>.
</p>

<!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="accept"> 
server:<b>accept()</b>
</p>

<p class=description>
Waits  for  a  remote connection on the server
object and returns a client object representing that connection.
</p>

<p class=return>
If a connection is successfully initiated, a client object is returned.  
If a  timeout condition  is  met,  the method  returns <b><tt>nil</tt></b>
followed by the error string '<tt>timeout</tt>'. Other errors are 
reported by <b><tt>nil</tt></b> followed by a message describing the error.
</p>

<p class=note>
Note: calling <a href=socket.html#select><tt>socket.select</tt></a>
with   a  server   object   in
the <tt>recvt</tt>  parameter  before  a   call  to  <tt>accept</tt> does
<em>not</em> guarantee  <tt>accept</tt> will  return immediately.  Use the <a
href=#settimeout><tt>settimeout</tt></a> method or <tt>accept</tt>
might block until <em>another</em> client shows up. 
</p>

<!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="bind"> 
master:<b>bind(</b>address, port<b>)</b>
</p>

<p class=description>
Binds a master object to <tt>address</tt> and <tt>port</tt> on the
local host. 

<p class=parameters>
<tt>Address</tt> can be an IP address or a host name. 
<tt>Port</tt> must be an integer number in the range [0..64K). 
If <tt>address</tt>
is '<tt>*</tt>', the system binds to all local interfaces
using the <tt>INADDR_ANY</tt> constant or
<tt>IN6ADDR_ANY_INIT</tt>, according to the family. 
If <tt>port</tt> is 0, the system automatically
chooses an ephemeral port.  
</p>

<p class=return>
In case of  success, the  method returns  1. In case of error, the
method returns <b><tt>nil</tt></b> followed by an error message.
</p>

<p class=note>
Note: The function <a href=socket.html#bind><tt>socket.bind</tt></a> 
is available and is a shortcut for the creation of server sockets.
</p>

<!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="close"> 
master:<b>close()</b><br>
client:<b>close()</b><br>
server:<b>close()</b>
</p>

<p class=description>
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
(except  for  further calls  to the <tt>close</tt> method)  are allowed on
a closed socket. 
</p>

<p class=note>
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
automatically closed before destruction, though. 
</p>

<!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="connect">
master:<b>connect(</b>address, port<b>)</b>
</p>

<p class=description>
Attempts to connect a master object to a remote host, transforming it into a
client object. 
Client objects support methods 
<a href=#send><tt>send</tt></a>,
<a href=#receive><tt>receive</tt></a>, 
<a href=#getsockname><tt>getsockname</tt></a>, 
<a href=#getpeername><tt>getpeername</tt></a>,
<a href=#settimeout><tt>settimeout</tt></a>, 
and <a href=#close><tt>close</tt></a>.
</p>

<p class=parameters>
<tt>Address</tt> can be an IP address or a host name. 
<tt>Port</tt> must be an integer number in the range [1..64K). 
</p>

<p class=return>
In case of error, the method returns <b><tt>nil</tt></b> followed by a string
describing the error. In case of success, the method returns 1.
</p>

<p class=note>
Note: The function <a href=socket.html#connect><tt>socket.connect</tt></a> 
is available and is a shortcut for the creation of client sockets.
</p>

<p class=note>
Note: Starting with LuaSocket 2.0, 
the <a href=#settimeout><tt>settimeout</tt></a>
method affects the behavior of <tt>connect</tt>, causing it to return 
with an error in case of a timeout. If that happens, you can still call <a
href=socket.html#select><tt>socket.select</tt></a> with the socket in the
<tt>sendt</tt> table. The socket will be writable when the connection is
established.
</p>

<p class=note>
Note: Starting with LuaSocket 3.0, the host name resolution
depends on whether the socket was created by <a
href=#socket.tcp><tt>socket.tcp</tt></a> or <a
href=#socket.tcp6><tt>socket.tcp6</tt></a>. Addresses from
the appropriate family are tried in succession until the
first success or until the last failure.
</p>

<!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="getpeername">
client:<b>getpeername()</b>
</p>

<p class=description>
Returns information about the remote side of a connected client object.
</p>

<p class=return>
Returns a string with the IP address of the peer, the 
port number that peer is using for the connection, 
and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). 
In case of error, the method returns <b><tt>nil</tt></b>. 
</p>

<p class=note>
Note: It makes no sense to call this method on server objects.
</p>

<!-- getsockname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="getsockname">
master:<b>getsockname()</b><br>
client:<b>getsockname()</b><br>
server:<b>getsockname()</b>
</p>

<p class=description>
Returns the local address information associated to the object. 
</p>

<p class=return>
The method returns a string with local IP address, a number with 
the local port, 
and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). 
In case of error, the method returns <b><tt>nil</tt></b>.
</p>

<!-- getstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="getstats">
master:<b>getstats()</b><br>
client:<b>getstats()</b><br>
server:<b>getstats()</b><br>
</p>

<p class=description>
Returns accounting information on the socket, useful for throttling
of bandwidth. 
</p>

<p class=return>
The method returns the number of bytes received, the number of bytes sent,
and the age of the socket object in seconds. 
</p>

<!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="listen"> 
master:<b>listen(</b>backlog<b>)</b>
</p>

<p class=description>
Specifies the socket is willing to receive connections, transforming the
object into a server object.  Server objects support the 
<a href=#accept><tt>accept</tt></a>,  
<a href=#getsockname><tt>getsockname</tt></a>, 
<a href=#setoption><tt>setoption</tt></a>, 
<a href=#settimeout><tt>settimeout</tt></a>, 
and <a href=#close><tt>close</tt></a> methods.  
</p>

<p class=parameters>
The parameter <tt>backlog</tt> 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.
</p>

<p class=return>
In case of  success, the  method returns  1. In case of error, the
method returns <b><tt>nil</tt></b> followed by an error message.
</p>

<!-- receive ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="receive">
client:<b>receive(</b>[pattern [, prefix]]<b>)</b>
</p>

<p class=description>
Reads data from a client object, according to the specified <em>read
pattern</em>.  Patterns follow the Lua file I/O format, and the difference in performance between all patterns is negligible. 
</p>

<p class=parameters>
<tt>Pattern</tt> can be any of the following: 
</p>

<ul>
<li> '<tt>*a</tt>':  reads from  the  socket  until the  connection  is
closed. No end-of-line translation is performed;
<li> '<tt>*l</tt>':  reads a line of  text from the socket.  The line is
terminated by a  LF character (ASCII&nbsp;10), optionally  preceded by a
CR character (ASCII&nbsp;13). The CR and LF characters are not included in
the returned line. In fact, <em>all</em> CR characters are
ignored by the pattern. This is the default pattern;
<li> <tt>number</tt>:  causes the  method to read  a specified <tt>number</tt> 
of bytes from the socket.
</ul>

<p class=parameters>
<tt>Prefix</tt> is an optional string to be concatenated to the beginning
of any received data before return.
</p>

<p class=return>
If successful, the method returns the received pattern. In case of error,
the method returns <tt><b>nil</b></tt> followed by an error
message, followed by a (possibly empty) string containing
the partial that was received. The error message can be
the string '<tt>closed</tt>'  in   case  the  connection  was
closed  before  the transmission  was completed  or  the string
'<tt>timeout</tt>' in  case there was a timeout during  the operation.
</p>

<p class=note>
<b>Important note</b>: This function was changed <em>severely</em>. 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 
way as successful results. This last feature violated the idea that all
functions should return <tt><b>nil</b></tt> on error.  Thus it was changed
too. 
</p>

<!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="send">
client:<b>send(</b>data [, i [, j]]<b>)</b>
</p>

<p class=description>
Sends <tt>data</tt> through client object.
</p>

<p class=parameters>
<tt>Data</tt> is the string to be sent. The optional arguments
<tt>i</tt> and <tt>j</tt> work exactly like the standard
<tt>string.sub</tt> Lua function to allow the selection of a 
substring to be sent.
</p>

<p class=return>
If successful, the method returns the index of the last byte
within <tt>[i, j]</tt> that has been sent.  Notice that, if
<tt>i</tt> is 1 or absent, this is effectively the total
number of bytes sent.  In case of error, the method returns
<b><tt>nil</tt></b>, followed by an error message, followed
by the index of the last byte within <tt>[i, j]</tt> that
has been sent. You might want to try again from the byte
following that.  The error message can be '<tt>closed</tt>'
in case the connection was  closed before the transmission
was  completed or the string  '<tt>timeout</tt>'  in  case
there was  a  timeout  during  the operation.
</p>

<p class=note>
Note: Output is <em>not</em> buffered. For small strings, 
it is always better to concatenate them in Lua 
(with the '<tt>..</tt>' operator) and send the result in one call 
instead of calling the method several times. 
</p>

<!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="setoption">
client:<b>setoption(</b>option [, value]<b>)</b><br>
server:<b>setoption(</b>option [, value]<b>)</b>
</p>

<p class=description>
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. 
</p>

<p class=parameters>
<tt>Option</tt> is a string with the option name, and <tt>value</tt> 
depends on the option being set:

<ul>

<li> '<tt>keepalive</tt>':  Setting this option to <tt>true</tt> 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; 

<li> '<tt>linger</tt>': Controls the action taken when unsent data are
queued on a socket and a close is performed.  The value is a table with a
boolean entry '<tt>on</tt>' and a numeric entry for the time interval
'<tt>timeout</tt>' in seconds. If the '<tt>on</tt>' field is set to
<tt>true</tt>, the system will block the process on the close attempt until
it is able to transmit the data or until '<tt>timeout</tt>' has passed. If
'<tt>on</tt>' is <tt>false</tt> 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; 

<li> '<tt>reuseaddr</tt>': Setting this option indicates that the rules
used in validating addresses supplied in a call to 
<a href=#bind><tt>bind</tt></a> should allow reuse of local addresses;

<li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt> 
disables the Nagle's algorithm for the connection;

<li> '<tt>ipv6-v6only</tt>':
Setting this option to <tt>true</tt> restricts an <tt>inet6</tt> socket to
sending and receiving only IPv6 packets.
</ul>

<p class=return>
The method returns 1 in case of success, or <b><tt>nil</tt></b>
followed by an error message otherwise.
</p>

<p class=note>
Note: The descriptions above come from the man pages.
</p>

<!-- getoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="getoption">
client:<b>getoption(</b>option)</b><br>
server:<b>getoption(</b>option)</b>
</p>

<p class=description>
Gets options for the TCP object.
See <a href=#setoption><tt>setoption</tt></a> for description of the
option names and values.
</p>

<p class=parameters>
<tt>Option</tt> is a string with the option name.
<ul>

<li> '<tt>keepalive</tt>'
<li> '<tt>linger</tt>'
<li> '<tt>reuseaddr</tt>'
<li> '<tt>tcp-nodelay</tt>'
</ul>

<p class=return>
The method returns the option <tt>value</tt> in case of success, or
<b><tt>nil</tt></b> followed by an error message otherwise.
</p>

<!-- setstats +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="setstats">
master:<b>setstats(</b>received, sent, age<b>)</b><br>
client:<b>setstats(</b>received, sent, age<b>)</b><br>
server:<b>setstats(</b>received, sent, age<b>)</b><br>
</p>

<p class=description>
Resets accounting information on the socket, useful for throttling
of bandwidth. 
</p>

<p class=parameters>
<tt>Received</tt> is a number with the new number of bytes received.
<tt>Sent</tt> is a number with the new number of bytes sent.
<tt>Age</tt> is the new age in seconds.
</p>

<p class=return>
The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise. 
</p>

<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="settimeout">
master:<b>settimeout(</b>value [, mode]<b>)</b><br>
client:<b>settimeout(</b>value [, mode]<b>)</b><br>
server:<b>settimeout(</b>value [, mode]<b>)</b>
</p>

<p class=description>
Changes the timeout  values for the object. By default,
all I/O  operations are  blocking. That  is, any  call to  the methods
<a href=#send><tt>send</tt></a>, 
<a href=#receive><tt>receive</tt></a>, and 
<a href=#accept><tt>accept</tt></a>
will  block indefinitely,  until the operation completes.  The
<tt>settimeout</tt>  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.
</p>

<p class=parameters>
The amount of time to wait is specified  as  the
<tt>value</tt> parameter, in seconds. There  are two timeout  modes and
both can be used together for fine tuning: 
</p>

<ul>
<li> '<tt>b</tt>': <em>block</em> timeout.  Specifies the upper limit on
the amount  of time  LuaSocket can  be blocked  by the  operating system
while waiting for completion of any single I/O operation. This is the
default mode;</li>

<li> '<tt>t</tt>':  <em>total</em> timeout. Specifies the  upper limit on
the amount of  time LuaSocket can block a Lua  script before returning from
a call.</li> 
</ul>

<p class=parameters>
The  <b><tt>nil</tt></b>  timeout  <tt>value</tt> allows  operations  to  block
indefinitely. Negative timeout values have the same effect.
</p>

<p class=note>
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
and to and from the Lua interpreter. Also, function that accept host names
and perform automatic name resolution might be blocked by the resolver for
longer than the specified timeout value.
</p>

<p class=note>
Note: The old <tt>timeout</tt> 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.
</p>

<!-- shutdown +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="shutdown">
client:<b>shutdown(</b>mode<b>)</b><br>
</p>

<p class=description>
Shuts down part of a full-duplex connection. 
</p>

<p class=parameters>
Mode tells which way of the connection should be shut down and can
take the value:
<ul>
<li>"<tt>both</tt>": disallow further sends and receives on the object.
This is the default mode;
<li>"<tt>send</tt>": disallow further sends on the object;
<li>"<tt>receive</tt>": disallow further receives on the object.
</ul>

<p class=return>
This function returns 1.
</p>

<!-- dirty +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="dirty">
master:<b>dirty()</b><br>
client:<b>dirty()</b><br>
server:<b>dirty()</b>
</p>

<p class=description>
Check the read buffer status.
</p>

<p class=return>
Returns <tt>true</tt> if there is any data in the read buffer, <tt>false</tt> otherwise.
</p>

<p class=note>
Note: <b>This is an internal method, any use is unlikely to be portable.</b>
</p>

<!-- getfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="getfd">
master:<b>getfd()</b><br>
client:<b>getfd()</b><br>
server:<b>getfd()</b>
</p>

<p class=description>
Returns the underling socket descriptor or handle associated to the object. 
</p>

<p class=return>
The descriptor or handle. In case the object has been closed, the return will be -1.
</p>

<p class=note>
Note: <b>This is an internal method, any use is unlikely to be portable.</b>
</p>

<!-- setfd +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="setfd">
master:<b>setfd(</b>fd<b>)</b><br>
client:<b>setfd(</b>fd<b>)</b><br>
server:<b>setfd(</b>fd<b>)</b>
</p>

<p class=description>
Sets the underling socket descriptor or handle associated to the object. The current one is simply replaced, not closed, and no other change to the object state is made.
</p>

<p class=return>
No return value.
</p>

<p class=note>
Note: <b>This is an internal method, any use is unlikely to be portable.</b>
</p>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:25:57 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\4�;BBudp.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: The UDP support">
<meta name="keywords" content="Lua, LuaSocket, Socket, UDP, Library, Network, Support"> 
<title>LuaSocket: UDP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>


<!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id="udp">UDP</h2> 

<!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="socket.udp">
socket.<b>udp()</b>
</p>

<p class="description">
Creates and returns an unconnected IPv4 UDP object. 
Unconnected objects support the 
<a href="#sendto"><tt>sendto</tt></a>, 
<a href="#receive"><tt>receive</tt></a>, 
<a href="#receivefrom"><tt>receivefrom</tt></a>, 
<a href="#getoption"><tt>getoption</tt></a>, 
<a href="#getsockname"><tt>getsockname</tt></a>, 
<a href="#setoption"><tt>setoption</tt></a>, 
<a href="#settimeout"><tt>settimeout</tt></a>, 
<a href="#setpeername"><tt>setpeername</tt></a>, 
<a href="#setsockname"><tt>setsockname</tt></a>, and 
<a href="#close"><tt>close</tt></a>. 
The <a href="#setpeername"><tt>setpeername</tt></a> 
is used to connect the object.
</p>

<p class="return">
In case of success, a new unconnected UDP object
returned. In case of error, <b><tt>nil</tt></b> is returned, followed by
an error message.
</p>

<!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="socket.udp6">
socket.<b>udp6()</b>
</p>

<p class="description">
Creates and returns an unconnected IPv6 UDP object. 
Unconnected objects support the 
<a href="#sendto"><tt>sendto</tt></a>, 
<a href="#receive"><tt>receive</tt></a>, 
<a href="#receivefrom"><tt>receivefrom</tt></a>, 
<a href="#getoption"><tt>getoption</tt></a>, 
<a href="#getsockname"><tt>getsockname</tt></a>, 
<a href="#setoption"><tt>setoption</tt></a>, 
<a href="#settimeout"><tt>settimeout</tt></a>, 
<a href="#setpeername"><tt>setpeername</tt></a>, 
<a href="#setsockname"><tt>setsockname</tt></a>, and 
<a href="#close"><tt>close</tt></a>. 
The <a href="#setpeername"><tt>setpeername</tt></a> 
is used to connect the object.
</p>

<p class="return">
In case of success, a new unconnected UDP object
returned. In case of error, <b><tt>nil</tt></b> is returned, followed by
an error message.
</p>

<p class=note>
Note: The TCP object returned will have the option
"<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>.
</p>



<!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="close">
connected:<b>close()</b><br>
unconnected:<b>close()</b>
</p>

<p class="description">
Closes a UDP 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 (except for further calls to the <tt>close</tt>
method) are allowed on a closed socket.
</p>

<p class="note">
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 automatically closed before
destruction, though.
</p>

<!-- getpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="getpeername">
connected:<b>getpeername()</b>
</p>

<p class="description">
Retrieves information about the peer
associated with a connected UDP object.
</p>


<p class=return>
Returns a string with the IP address of the peer, the 
port number that peer is using for the connection, 
and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). 
In case of error, the method returns <b><tt>nil</tt></b>. 
</p>

<p class="note">
Note: It makes no sense to call this method on unconnected objects.
</p>

<!-- getsockname +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="getsockname">
connected:<b>getsockname()</b><br>
unconnected:<b>getsockname()</b>
</p>

<p class="description">
Returns the local address information associated to the object.
</p>


<p class=return>
The method returns a string with local IP address, a number with 
the local port, 
and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). 
In case of error, the method returns <b><tt>nil</tt></b>.
</p>

<p class="note">
Note: UDP sockets are not bound to any address
until the <a href="#setsockname"><tt>setsockname</tt></a> or the
<a href="#sendto"><tt>sendto</tt></a> method is called for the
first time (in which case it is bound to an ephemeral port and the
wild-card address).
</p>

<!-- receive +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="receive">
connected:<b>receive(</b>[size]<b>)</b><br>
unconnected:<b>receive(</b>[size]<b>)</b>
</p>

<p class="description">
Receives a datagram from the UDP object. If
the UDP object is connected, only datagrams coming from the peer
are accepted. Otherwise, the returned datagram can come from any
host.
</p>

<p class="parameters">
The optional <tt>size</tt> parameter
specifies the maximum size of the datagram to be retrieved. If
there are more than <tt>size</tt> bytes available in the datagram,
the excess bytes are discarded. If there are less then
<tt>size</tt> bytes available in the current datagram, the
available bytes are returned. If <tt>size</tt> is omitted, the
maximum datagram size is used (which is currently limited by the
implementation to 8192 bytes).
</p>

<p class="return">
In case of success, the method returns the
received datagram. In case of timeout, the method returns
<b><tt>nil</tt></b> followed by the string '<tt>timeout</tt>'.
</p>

<!-- receivefrom +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="receivefrom">
unconnected:<b>receivefrom(</b>[size]<b>)</b>
</p>

<p class="description">
Works exactly as the <a href="#receive"><tt>receive</tt></a> 
method, except it returns the IP
address and port as extra return values (and is therefore slightly less
efficient).
</p>

<!-- getoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="getoption">
connected:<b>getoption()</b><br>
unconnected:<b>getoption()</b>
</p>

<p class="description">
Gets an option value from the UDP object.
See <a href=#setoption><tt>setoption</tt></a> for
description of the option names and values.
</p>

<p class="parameters"><tt>Option</tt> is a string with the option name. 
<ul>
<li> '<tt>dontroute</tt>'
<li> '<tt>broadcast</tt>'
<li> '<tt>reuseaddr</tt>'
<li> '<tt>reuseport</tt>'
<li> '<tt>ip-multicast-loop</tt>'
<li> '<tt>ipv6-v6only</tt>'
<li> '<tt>ip-multicast-if</tt>'
<li> '<tt>ip-multicast-ttl</tt>'
<li> '<tt>ip-add-membership</tt>' 
<li> '<tt>ip-drop-membership</tt>'
</ul> 
</p>

<p class=return>
The method returns the option <tt>value</tt> in case of
success, or
<b><tt>nil</tt></b> followed by an error message otherwise.
</p>

<!-- send ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="send">
connected:<b>send(</b>datagram<b>)</b>
</p>

<p class="description">
Sends a datagram to the UDP peer of a connected object.
</p>

<p class="parameters">
<tt>Datagram</tt> is a string with the datagram contents. 
The maximum datagram size for UDP is 64K minus IP layer overhead.
However datagrams larger than the link layer packet size will be
fragmented, which may deteriorate performance and/or reliability.
</p>

<p class="return">
If successful, the method returns 1. In case of
error, the method returns <b><tt>nil</tt></b> followed by an error message.
</p>

<p class="note">
Note: In UDP, the <tt>send</tt> method never blocks
and the only way it can fail is if the underlying transport layer
refuses to send a message to the specified address (i.e. no
interface accepts the address).
</p>

<!-- sendto ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="sendto">
unconnected:<b>sendto(</b>datagram, ip, port<b>)</b>
</p>

<p class="description">
Sends a datagram to the specified IP address and port number.
</p>

<p class="parameters">
<tt>Datagram</tt> is a string with the
datagram contents. 
The maximum datagram size for UDP is 64K minus IP layer overhead.
However datagrams larger than the link layer packet size will be
fragmented, which may deteriorate performance and/or reliability.
<tt>Ip</tt> is the IP address of the recipient. 
Host names are <em>not</em> allowed for performance reasons.

<tt>Port</tt> is the port number at the recipient.
</p>

<p class="return">
If successful, the method returns 1. In case of
error, the method returns <b><tt>nil</tt></b> followed by an error message.
</p>

<p class="note">
Note: In UDP, the <tt>send</tt> method never blocks
and the only way it can fail is if the underlying transport layer
refuses to send a message to the specified address (i.e. no
interface accepts the address).
</p>

<!-- setpeername +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="setpeername">
connected:<b>setpeername(</b>'*'<b>)</b><br>
unconnected:<b>setpeername(</b>address, port<b>)</b>
</p>

<p class="description">
Changes the peer of a UDP object. This
method turns an unconnected UDP object into a connected UDP
object or vice versa.
</p>

<p class="description">
For connected objects, outgoing datagrams
will be sent to the specified peer, and datagrams received from
other peers will be discarded by the OS. Connected UDP objects must
use the <a href="#send"><tt>send</tt></a> and 
<a href="#receive"><tt>receive</tt></a> methods instead of 
<a href="#sendto"><tt>sendto</tt></a> and 
<a href="#receivefrom"><tt>receivefrom</tt></a>.
</p>

<p class="parameters">
<tt>Address</tt> can be an IP address or a
host name. <tt>Port</tt> is the port number. If <tt>address</tt> is
'<tt>*</tt>' and the object is connected, the peer association is
removed and the object becomes an unconnected object again. In that
case, the <tt>port</tt> argument is ignored.
</p>

<p class="return">
In case of error the method returns
<b><tt>nil</tt></b> followed by an error message. In case of success, the
method returns 1.
</p>

<p class="note">
Note: Since the address of the peer does not have
to be passed to and from the OS, the use of connected UDP objects
is recommended when the same peer is used for several transmissions
and can result in up to 30% performance gains.
</p>

<p class=note>
Note: Starting with LuaSocket 3.0, the host name resolution
depends on whether the socket was created by <a
href=#socket.udp><tt>socket.udp</tt></a> or <a
href=#socket.udp6><tt>socket.udp6</tt></a>. Addresses from
the appropriate family are tried in succession until the
first success or until the last failure.
</p>

<!-- setsockname +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="setsockname">
unconnected:<b>setsockname(</b>address, port<b>)</b>
</p>

<p class="description">
Binds the UDP object to a local address.
</p>

<p class="parameters">
<tt>Address</tt> can be an IP address or a
host name. If <tt>address</tt> is '<tt>*</tt>' the system binds to
all local interfaces using the constant <tt>INADDR_ANY</tt>. If
<tt>port</tt> is 0, the system chooses an ephemeral port.
</p>

<p class="return">
If successful, the method returns 1. In case of
error, the method returns <b><tt>nil</tt></b> followed by an error
message.
</p>

<p class="note">
Note: This method can only be called before any
datagram is sent through the UDP object, and only once. Otherwise,
the system automatically binds the object to all local interfaces
and chooses an ephemeral port as soon as the first datagram is
sent. After the local address is set, either automatically by the
system or explicitly by <tt>setsockname</tt>, it cannot be
changed.
</p>

<!-- setoption +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="setoption">
connected:<b>setoption(</b>option [, value]<b>)</b><br>
unconnected:<b>setoption(</b>option [, value]<b>)</b>
</p>

<p class="description">
Sets options for the UDP 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.</p>
<p class="parameters"><tt>Option</tt> is a string with the option
name, and <tt>value</tt> depends on the option being set:
</p>

<ul> 
<li> '<tt>dontroute</tt>': Indicates that outgoing
messages should bypass the standard routing facilities.
Receives a boolean value;
<li> '<tt>broadcast</tt>': Requests permission to send 
broadcast datagrams on the socket.
Receives a boolean value;
<li> '<tt>reuseaddr</tt>': Indicates that the rules used in
validating addresses supplied in a <tt>bind()</tt> call 
should allow reuse of local addresses. 
Receives a boolean value;
<li> '<tt>reuseport</tt>': Allows completely duplicate
bindings by multiple processes if they all set
'<tt>reuseport</tt>' before binding the port.
Receives a boolean value;
<li> '<tt>ip-multicast-loop</tt>':
Specifies whether or not a copy of an outgoing multicast
datagram is delivered to the sending host as long as it is a
member of the multicast group.
Receives a boolean value;
<li> '<tt>ipv6-v6only</tt>':
Specifies whether to restrict <tt>inet6</tt> sockets to 
sending and receiving only IPv6 packets.
Receive a boolean value;
<li> '<tt>ip-multicast-if</tt>':
Sets the interface over which outgoing multicast datagrams
are sent.
Receives an IP address;
<li> '<tt>ip-multicast-ttl</tt>':
Sets the Time To Live in the IP header for outgoing
multicast datagrams. 
Receives a number;
<li> '<tt>ip-add-membership</tt>': 
Joins the multicast group specified.
Receives a table with fields
<tt>multiaddr</tt> and <tt>interface</tt>, each containing an
IP address;
<li> '<tt>ip-drop-membership</tt>': Leaves the multicast
group specified.
Receives a table with fields
<tt>multiaddr</tt> and <tt>interface</tt>, each containing an
IP address.
</ul> 

<p class="return">
The method returns 1 in case of success, or
<b><tt>nil</tt></b> followed by an error message otherwise.
</p>

<p class=note>
Note: The descriptions above come from the man pages.
</p>

<!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class="name" id="settimeout">
connected:<b>settimeout(</b>value<b>)</b><br>
unconnected:<b>settimeout(</b>value<b>)</b>
</p>

<p class="description">
Changes the timeout values for the object.  By default, the 
<a href="#receive"><tt>receive</tt></a> and 
<a href="#receivefrom"><tt>receivefrom</tt></a> 
operations are blocking. That is, any call to the methods will block
indefinitely, until data arrives.  The <tt>settimeout</tt> function defines
a limit on the amount of time the functions 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.  
</p>

<p class="parameters">
The amount of time to wait is specified as
the <tt>value</tt> parameter, in seconds. The <b><tt>nil</tt></b> timeout
<tt>value</tt> allows operations to block indefinitely. Negative
timeout values have the same effect.
</p>

<p class="note">
Note: In UDP, the <a href="#send"><tt>send</tt></a>
and <a href="#sentdo"><tt>sendto</tt></a> methods never block (the
datagram is just passed to the OS and the call returns
immediately). Therefore, the <tt>settimeout</tt> method has no
effect on them.
</p>

<p class="note">
Note: The old <tt>timeout</tt> 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.
</p>

<!-- footer ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:26:01 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\ Rj�� � url.htmlnu�[���<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta name="description" content="LuaSocket: URL manipulation">
<meta name="keywords" content="Lua, LuaSocket, URL, Library, Link, Network, Support"> 
<title>LuaSocket: URL support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>

<body>

<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=header>
<hr>
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
</table>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a> 
</p>
</center>
<hr>
</div>

<!-- url ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h2 id="url">URL</h2> 

<p>
The  <tt>url</tt>  namespace provides  functions  to  parse,  protect,
and build URLs, as well  as functions to compose  absolute URLs
from base and relative URLs, according to 
<a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>.
</p>

<p> 
To obtain the <tt>url</tt> namespace, run:
</p>

<pre class=example>
-- loads the URL module 
local url = require("socket.url")
</pre>

<p>
An URL is defined by the following grammar:
</p>

<blockquote>
<tt>
&lt;url&gt; ::= [&lt;scheme&gt;:][//&lt;authority&gt;][/&lt;path&gt;][;&lt;params&gt;][?&lt;query&gt;][#&lt;fragment&gt;]<br>
&lt;authority&gt; ::= [&lt;userinfo&gt;@]&lt;host&gt;[:&lt;port&gt;]<br>
&lt;userinfo&gt; ::= &lt;user&gt;[:&lt;password&gt;]<br>
&lt;path&gt; ::= {&lt;segment&gt;/}&lt;segment&gt;<br>
</tt>
</blockquote>

<!-- absolute +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="absolute">
url.<b>absolute(</b>base, relative<b>)</b>
</p>

<p class=description>
Builds an absolute URL from a base URL and a relative URL. 
</p>

<p class=parameters>
<tt>Base</tt> is a string with the base URL or
a parsed URL table.  <tt>Relative</tt> is a
string with the relative URL.
</p>

<p class=return>
The function returns a string with the absolute URL.
</p>

<p class=note>
Note: The rules that
govern the composition are fairly complex, and are described in detail in
<a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>.
The example bellow should give an idea of what the rules are.
</p>

<pre class=example>
http://a/b/c/d;p?q

+

g:h      =  g:h
g        =  http://a/b/c/g
./g      =  http://a/b/c/g
g/       =  http://a/b/c/g/
/g       =  http://a/g
//g      =  http://g
?y       =  http://a/b/c/?y
g?y      =  http://a/b/c/g?y
#s       =  http://a/b/c/d;p?q#s
g#s      =  http://a/b/c/g#s
g?y#s    =  http://a/b/c/g?y#s
;x       =  http://a/b/c/;x
g;x      =  http://a/b/c/g;x
g;x?y#s  =  http://a/b/c/g;x?y#s
.        =  http://a/b/c/
./       =  http://a/b/c/
..       =  http://a/b/
../      =  http://a/b/
../g     =  http://a/b/g
../..    =  http://a/
../../   =  http://a/
../../g  =  http://a/g
</pre>

<!-- build ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="build">
url.<b>build(</b>parsed_url<b>)</b>
</p>

<p class=description>
Rebuilds an URL from its parts. 
</p>

<p class=parameters>
<tt>Parsed_url</tt> is a table with same components returned by
<a href="#parse"><tt>parse</tt></a>.
Lower level components, if specified,
take  precedence over  high level  components of  the URL grammar. 
</p>

<p class=return>
The function returns a string with the built URL.
</p>

<!-- build_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="build_path">
url.<b>build_path(</b>segments, unsafe<b>)</b>
</p>

<p class=description>
Builds a <tt>&lt;path&gt;</tt> component from  a list of
<tt>&lt;segment&gt;</tt> parts. 
Before composition, any reserved characters found in a segment are escaped into
their protected  form, so that  the resulting path  is a valid  URL path
component.  
</p>

<p class=parameters>
<tt>Segments</tt> is a list of strings with the <tt>&lt;segment&gt;</tt>
parts. If <tt>unsafe</tt>  is anything  but <b><tt>nil</tt></b>,  reserved
characters are left untouched.
</p>

<p class=return>
The  function  returns   a string with the  
built <tt>&lt;path&gt;</tt> component. 
</p>

<!-- escape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="escape">
url.<b>escape(</b>content<b>)</b>
</p>

<p class=description>
Applies the URL escaping content coding to a string
Each byte is encoded as a percent character followed
by the two byte hexadecimal representation of its integer 
value.
</p>

<p class=parameters>
<tt>Content</tt> is the string to be encoded.
</p>

<p class=result>
The function returns the encoded string.
</p>

<pre class=example>
-- load url module
url = require("socket.url")

code = url.escape("/#?;")
-- code = "%2f%23%3f%3b"
</pre>

<!-- parse ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="parse">
url.<b>parse(</b>url, default<b>)</b>
</p>

<p class=description>
Parses an URL given as a string into a Lua table with its components.
</p>

<p class=parameters>
<tt>Url</tt> is the URL to be parsed. If the <tt>default</tt> table is
present, it is used to store the parsed fields. Only fields present in the
URL are overwritten. Therefore, this table can be used to pass default
values for each field.
</p>

<p class=return>
The function returns a table with all the URL components:
</p>

<blockquote><tt>
parsed_url = {<br>
&nbsp;&nbsp;url = <i>string</i>,<br>
&nbsp;&nbsp;scheme = <i>string</i>,<br>
&nbsp;&nbsp;authority = <i>string</i>,<br>
&nbsp;&nbsp;path = <i>string</i>,<br>
&nbsp;&nbsp;params = <i>string</i>,<br>
&nbsp;&nbsp;query = <i>string</i>,<br>
&nbsp;&nbsp;fragment = <i>string</i>,<br>
&nbsp;&nbsp;userinfo = <i>string</i>,<br>
&nbsp;&nbsp;host = <i>string</i>,<br>
&nbsp;&nbsp;port = <i>string</i>,<br>
&nbsp;&nbsp;user = <i>string</i>,<br>
&nbsp;&nbsp;password = <i>string</i><br>
}
</tt></blockquote>

<pre class=example>
-- load url module
url = require("socket.url")

parsed_url = url.parse("http://www.example.com/cgilua/index.lua?a=2#there")
-- parsed_url = {
--   scheme = "http",
--   authority = "www.example.com",
--   path = "/cgilua/index.lua"
--   query = "a=2",
--   fragment = "there",
--   host = "www.puc-rio.br",
-- }

parsed_url = url.parse("ftp://root:passwd@unsafe.org/pub/virus.exe;type=i")
-- parsed_url = {
--   scheme = "ftp",
--   authority = "root:passwd@unsafe.org",
--   path = "/pub/virus.exe",
--   params = "type=i",
--   userinfo = "root:passwd",
--   host = "unsafe.org",
--   user = "root",
--   password = "passwd",
-- }
</pre>

<!-- parse_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="parse_path">
url.<b>parse_path(</b>path<b>)</b>
</p>

<p class=description>
Breaks a <tt>&lt;path&gt;</tt> URL component into all its 
<tt>&lt;segment&gt;</tt> parts. 
</p>

<p class=description>
<tt>Path</tt> is a string with the path to be parsed.
</p>

<p class=return>
Since  some characters   are   reserved   in   URLs,  they must be escaped
whenever present in a <tt>&lt;path&gt;</tt> component. Therefore, before
returning a list with all the parsed segments, the function removes
escaping from all of them. 
</p>

<!-- unescape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<p class=name id="unescape">
url.<b>unescape(</b>content<b>)</b>
</p>

<p class=description>
Removes  the   URL   escaping    content   coding   from   a string.
</p>

<p class=parameters>
<tt>Content</tt> is the string to be decoded.
</p>

<p class=return>
The function returns the decoded string. 
</p>

<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<div class=footer>
<hr>
<center>
<p class=bar>
<a href="index.html">home</a> &middot;
<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
<p>
<small>
Last modified by Diego Nehab on <br>
Thu Apr 20 00:26:05 EDT 2006
</small>
</p>
</center>
</div>

</body>
</html>
PKN��\�)����READMEnu�[���PKN��\��ξff#dns.htmlnu�[���PKN��\�b�]%]%�ftp.htmlnu�[���PKN��\s�if�,�,	V9http.htmlnu�[���PKN��\>�-��
Hfindex.htmlnu�[���PKN��\-)
D++�installation.htmlnu�[���PKN��\I���0�0�introduction.htmlnu�[���PKN��\=]aڸ*�*
Q�ltn12.htmlnu�[���PKN��\��TX��	C�lua05.pptnu�[���PKN��\l����-�-
|�luasocket.pngnu�[���PKN��\~�@�P7P7	��mime.htmlnu�[���PKN��\޶j���
�reference.cssnu�[���PKN��\�ߝ��	�reference.htmlnu�[���PKN��\e�f��8�8	�smtp.htmlnu�[���PKN��\���*6*6�Ssocket.htmlnu�[���PKN��\�4���S�S+�tcp.htmlnu�[���PKN��\4�;BB5�udp.htmlnu�[���PKN��\ Rj�� � � url.htmlnu�[���PK;�A