Added new instalation section to the manual.

This commit is contained in:
Diego Nehab 2004-11-28 08:17:16 +00:00
parent 297b32e828
commit 534b0cedf7
17 changed files with 264 additions and 89 deletions

6
TODO
View File

@ -1,6 +1,3 @@
use wim's filter.chain or something better
make sure standard libraries are "required" by modules before use.
eliminate globals from namespaces created by module().
ftp.send/recv return bytes transfered?
new scheme to choose family/protocol of object to create
change ltn13 to make sure drawbacks are obvious
@ -23,6 +20,9 @@ testar os options!
- proteger ou atomizar o conjunto (timedout, receive), (timedout, send)
- inet_ntoa também é uma merda.
*eliminate globals from namespaces created by module().
*make sure standard libraries are "required" by modules before use.
*use wim's filter.chain or something better
*close wasn't returning 1
*make sure errors not thrown by try() are not caught by protect()
*move wsocket.c:sock_send kludge to buffer.c:sendraw?

View File

@ -4,7 +4,7 @@
<head>
<meta name="description" content="LuaSocket: DNS support">
<meta name="keywords" content="Lua, Library, DNS, Network, 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>
@ -26,6 +26,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -114,6 +115,7 @@ message.
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,7 @@
<head>
<meta name="description" content="LuaSocket: FTP support">
<meta name="keywords" content="Lua, Library, FTP, Network, 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>
@ -26,6 +26,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -265,6 +266,7 @@ f, e = ftp.put{
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,7 @@
<head>
<meta name="description" content="LuaSocket: HTTP support">
<meta name="keywords" content="Lua, Library, HTTP, WWW, browser, Network, 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>
@ -27,6 +27,7 @@
<a href="home.html">home</a> &middot;
<a href="home.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>
@ -299,6 +300,7 @@ r, c = http.request {
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,7 @@
<head>
<meta name="description" content="The LuaSocket Homepage">
<meta name="keywords" content="Lua, Library, Network, Support, Internet">
<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>
@ -26,6 +26,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -79,7 +80,7 @@ LuaSocket.
</p>
<p>
Copyright &copy; 1999-2004 Tecgraf/PUC-Rio. All rights reserved. <br>
Copyright &copy; 2004 Diego Nehab. All rights reserved. <br>
Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a>
</p>
@ -88,7 +89,7 @@ Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a>
<h2 id=download>Download</h2>
<p>
LuaSocket version 2.0 beta2 is now available for download! It is
LuaSocket version 2.0 (beta3) is now available for download! It is
compatible with Lua&nbsp;5.0 and has been tested on
Windows&nbsp;XP, Linux, and Mac OS X.
</p>
@ -99,8 +100,8 @@ The library can be downloaded in source code from the following links:
<blockquote>
<p>
<a href="luasocket-2.0-beta2.tar.gz">luasocket-2.0-beta2.tar.gz</a> <br>
<a href="luasocket-2.0-beta2.zip">luasocket-2.0-beta2.zip</a>
<a href="luasocket-2.0-beta3.tar.gz">luasocket-2.0-beta3.tar.gz</a> <br>
<a href="luasocket-2.0-beta3.zip">luasocket-2.0-beta3.zip</a>
</p>
</blockquote>
@ -116,7 +117,7 @@ LuaSocket a quick try:
<blockquote>
<p>
<a href="luasocket-2.0-beta2-win32.zip">luasocket-2.0-beta2-win32.zip</a>
<a href="luasocket-2.0-beta3-win32.zip">luasocket-2.0-beta3-win32.zip</a>
</p>
</blockquote>
@ -124,11 +125,15 @@ LuaSocket a quick try:
The quick and dirty way to use these binaries is to unpack everything into a
directory, say <tt>c:\luasocket</tt> (include all Lua files from the
LuaSocket distrbitution in the same directory too!).
Then set <tt>LUA_INIT</tt> to load the <tt>lua.lua</tt> helper file:
Then set <tt>LUA_INIT</tt> to load the <tt>compat-5.1.lua</tt> and set
<tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt> to look for files in that
directory:
</p>
<pre class=example>
c:\luasocket\&gt; set LUA_INIT=@lua.lua
c:\luasocket\&gt; set LUA_INIT=@compat-5.1.lua
c:\luasocket\&gt; set LUA_CPATH=?.dll
c:\luasocket\&gt; set LUA_PATH=?.lua
</pre>
<p>
@ -142,9 +147,13 @@ c:\luasocket\&gt; lua
Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
&gt; http = require"http"
&gt; print(http.request"http://www.tecgraf.puc-rio.br/luasocket/")
--&gt; this file
--&gt; this gets dumped to terminal
</pre>
<p> Take a look at the <a href=instalation.html>installation</a> section of
the manual to find out how to properly install the library after you are
done playing with it. </p>
<!-- thanks +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2 id=thanks>Special thanks</h2>
@ -165,35 +174,31 @@ has been helping a lot too! Thanks to you all!
<h2 id=new>What's New</h2>
<p>
Changes in the 2.0-beta2 were mostly bug-fixes.
The big change for the 2.0 (beta3) release was the adoption of the Lua 5.1
package proposal. There were several bug fixes too (a beta is a
beta, is a beta).
</p>
<ul>
<li> Fixed silly last-minute-change bug in HTTP/SMTP;
<li> <tt>usocket.c</tt>/<tt>wsocket.c</tt> look nicer thanks to Mike;
<li> Finally total timeout is reliable on Windows! (found a pretty
simple work around);
<li> UDP has a reasonable maximum datagram size (8k);
<li> <tt>Receive</tt> accepts the prefix optional argument (good for
non-blocking);
<li> <b><tt>Send</tt> doesn't support multiple arguments anymore</b>;
<li> Instead, <tt>send</tt> allows the selection of the substring
to be sent (good for non-blocking);
<li> Fixed bug that caused select return tables not to be associative
on windows;
<li> Should compile with g++;
<li> New sample unix domain support;
<li> New sample LPD support;
<li> Comprehensive error messages;
<li> New <tt>getstats</tt> and <tt>setstats</tt> methods to help throttling;
<li> <tt>Listen</tt> defaults to 32 backlog;
<li> SMTP/FTP/HTTP fail gracefully;
<li> <tt>accept</tt>/<tt>connect</tt>/<tt>select</tt> interrupt safe
<li> Fixed bug that didn't set accepted sockets as non-blocking
<li> <b>New timming functions <tt>sleep</tt> and <tt>gettime</tt> have
higher resolution and no wrap around problems</b>;
<li> Bug fixes in the manual;
<li> Fixed bug of missing cast in <tt>getfd</tt>.
<li> New compat-5.1 distribution:
<ul>
<li> Instalation uses new directory structure;
<li> Namespace hierarchy is in now back in use (ex. <tt>socket.url</tt>
instead of <tt>url</tt>);
<li> Globals not visible from inside namespaces;
<li> All modules call <tt>require</tt> even for standard libraries;
</ul>
<li> LTN12 avoids coroutines (so you can go wild on the C side);
<li> Kludge on wsocket.c:sock_send for windows timeout issue
moved to buffer.c:sendraw;
<li> <tt>socket.protect </tt>only catches errors thrown by <tt>socket.try</tt>;
<li> Fixed <tt>udp:sendto</tt> to call <tt>sock_sendto</tt> instead of
<tt>sock_send</tt>;
<li> <tt>close</tt> wasn't returning 1!
<li> <tt>socket.gettime</tt> returns time since Unix Epoch 1/1/1970 (UTC)
<li> <tt>socket.sleep</tt> is robust to interrupts;
<li> <tt>socket.select</tt> wasn't calling <tt>tm_markstart</tt>;
<li> <tt>http.PROXY</tt> etc wasn't working.
</ul>
<!-- incompatible +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -201,10 +206,9 @@ higher resolution and no wrap around problems</b>;
<h3 id=incompatible>Incompatibilities with previous versions</h3>
<ul>
<li> New <tt>send</tt> inteface doesn't send multiple arguments anymore;
<li> <tt>Time</tt> is replaced by <tt>gettime</tt> with advantage.
<li> Namespaces are hierarchical again. This means that whoever called
<tt>require("url")</tt> should update their code to
<tt>require("socket.url")</tt>.
</ul>
<!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -225,6 +229,8 @@ those that have compatibility issues.
<center>
<p class=bar>
<a href="home.html#down">download</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

149
doc/installation.html Normal file
View File

@ -0,0 +1,149 @@
<!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: Instalation</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="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
</center>
<hr>
</div>
<!-- instalation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2>Instalation</h2>
<p> LuaSocket 2.0 uses the new package proposal for Lua 5.1, throught the
compatibility module <a href=http://www.keplerproject.org/compat/>
Compat-5.1</a> released in conjunction with Roberto Ierusalimschy and <a
href=http://www.keplerproject.org/">The Kepler project</a>. The proposal
was considered important enough by the community to justify early adoption.
All Lua library developers are encouraged to change their libraries in
preparation for the release of Lua 5.1. </p>
<p> As far as LuaSocket is concerned, this means that whoever is
deploying a solution that uses LuaSocket has a lot of freedom. Here we
describe only the standard distribution. If the standard doesn't meet your
needs, we refer you to the Lua discussion list, where any quesetion about
the package scheme will likely be answered promptly.
</p>
<h3>Directory structure</h3>
<p> The new package scheme has a root directory for the libraries installed
on a given system. Let's call this directory <tt>&lt;ROOT&gt;</tt>.
On my system, this is the <tt>/usr/local/share/lua/5.0</tt> directory.
Here is the standard LuaSocket distribution directory structure:</p>
<pre class=example>
&lt;ROOT&gt;/compat-5.1.lua
&lt;ROOT&gt;/socket.lua
&lt;ROOT&gt;/lsocket.dll
&lt;ROOT&gt;/mime.lua
&lt;ROOT&gt;/lmime.dll
&lt;ROOT&gt;/ltn12.lua
&lt;ROOT&gt;/socket/http.lua
&lt;ROOT&gt;/socket/tp.lua
&lt;ROOT&gt;/socket/ftp.lua
&lt;ROOT&gt;/socket/smtp.lua
&lt;ROOT&gt;/socket/url.lua
</pre>
<p> Naturally, on Unix systems, <tt>lsocket.dll</tt> and <tt>lmime.dll</tt>
would be replaced by <tt>lsocket.so</tt> and <tt>lmime.so</tt>. In Mac OS
X, they would be replaced by <tt>lsocket.dylib</tt> and
<tt>lmime.dylib</tt>. </p>
<p> In order for the interpreter to find all LuaSocket components, three
environment variables need to be set. The first environment variable tells
the interpreter to load the <tt>compat-5.1.lua</tt> module. </p>
<pre class=example>
LUA_INIT=@&lt;ROOT&gt;/compat-5.1.lua
</pre>
The other two environment variables instruct the compatibility module to
look for dynamic libraries and modules in the appropriate directories and
with the appropriate filename extensions.
<pre class=example>
LUA_PATH=&lt;ROOT&gt;/?.lua;?.lua
LUA_CPATH=&lt;ROOT&gt;/?.dll;?.dll
</pre>
<p> Again, naturally, in Unix the shared library extension would be
<tt>.so</tt> instead of <tt>.dll</tt> and on Mac OS X they would be
<tt>.dylib</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.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
&gt; socket = require("socket")
&gt; print(socket.VERSION)
--&gt; LuaSocket 2.0 (beta3)
</pre>
<p> Each module loads their dependencies automatically, so you only need to
load the modues you are directly dependent upon. <p>
<pre class=example>
Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
&gt; http = require("socket.http")
&gt; print(http.get("http://www.tecgraf.puc-rio.br/luasocket"))
--&gt; homepage gets dumped to terminal
</pre>
<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<div class=footer>
<hr>
<center>
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</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 Jun 17 02:47:21 EDT 2004
</small>
</p>
</center>
</div>
</body>
</html>

View File

@ -4,7 +4,8 @@
<head>
<meta name="description" content="LuaSocket: Introduction to the core">
<meta name="keywords" content="Lua, Library, TCP, UDP, Network, Support">
<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>
@ -26,6 +27,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -104,29 +106,6 @@ Together, these changes make network programming in LuaSocket much simpler
than it is in C, as the following sections will show.
</p>
<!-- initializing +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h3>Initializing the library</h3>
<p>
The core LuaSocket is almost entirely implemented in C. It is
usually available as a dynamic library which the interpreter can load
with the help of a loader module written in Lua.
Beginning with version 2.0 and following the Lua 5.0 trend, all LuaSocket
functionality is defined inside tables (or rather namespaces). No global
variables are ever created.
Namespaces are obtained with the <tt>require</tt> Lua function, which loads
and initializes any required library and returns the namespace.
For example, the core functionality or LuaSocket is usually available
from the "<tt>socket</tt>" namespace.
</p>
<pre class="example">
socket = require("socket")
print(socket.VERSION)
--&gt; LuaSocket 2.0
</pre>
<!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h3 id=tcp>TCP</h3>
@ -318,6 +297,17 @@ io.write(socket.try((udp:receive())))
</pre>
</blockquote>
<!-- More +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h3 id=more>Much more</h3>
<p> LuaSocket offers much more than TCP and UDP support. As the library
evolved, support for <a href=http.html>HTTP</a>, <a href=ftp.html>FTP</a>,
<a href=smtp.html>SMTP</a>, <a href=mime.html>MIME</a>, <a
href=url.html>URLs</a> and much more was made available.</a> These are
mostly implemented in Lua itself, with critical parts implemented in C for
efficiency</p>
<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<div class=footer>
@ -326,6 +316,7 @@ io.write(socket.try((udp:receive())))
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,8 +4,8 @@
<head>
<meta name="description" content="LuaSocket: LTN12 support">
<meta name="keywords" content="Lua, Library, Filters, Source, Sink,
Pump, 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>
@ -27,6 +27,7 @@ Pump, Support">
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -412,6 +413,7 @@ Creates and returns a source that produces the contents of a
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,7 @@
<head>
<meta name="description" content="LuaSocket: MIME support">
<meta name="keywords" content="Lua, Library, 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>
@ -26,6 +26,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -458,6 +459,7 @@ marker.
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,8 @@
<head>
<meta name="description" content="LuaSocket: Index to reference manual">
<meta name="keywords" content="Lua, Library, Index, Manual, Network, Support">
<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>
@ -26,6 +27,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -220,6 +222,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,8 @@
<head>
<meta name="description" content="LuaSocket: SMTP support">
<meta name="keywords" content="Lua, Library, SMTP, e-mail, MIME, Multipart, 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>
@ -26,6 +27,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -394,6 +396,7 @@ r, e = smtp.send{
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,7 @@
<head>
<meta name="description" content="LuaSocket: The core namespace">
<meta name="keywords" content="Lua, Library, socket, Network, Support">
<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>
@ -26,6 +26,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -382,6 +383,7 @@ This constant has a string describing the current LuaSocket version.
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,7 @@
<head>
<meta name="description" content="LuaSocket: The TCP/IP support">
<meta name="keywords" content="Lua, Library, socket, TCP, Network, 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>
@ -26,6 +26,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -527,6 +528,7 @@ This function returns 1.
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,7 @@
<head>
<meta name="description" content="LuaSocket: The UDP support">
<meta name="keywords" content="Lua, Library, socket, UDP, Network, 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>
@ -26,6 +26,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -398,6 +399,7 @@ imperative nature obvious.
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -4,7 +4,7 @@
<head>
<meta name="description" content="LuaSocket: URL manipulation">
<meta name="keywords" content="Lua, Library, URL, link, Network, Support">
<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>
@ -26,6 +26,7 @@
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#download">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>
@ -311,6 +312,7 @@ The function returns the decoded string.
<p class=bar>
<a href="home.html">home</a> &middot;
<a href="home.html#down">download</a> &middot;
<a href="instalation.html">instalation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
</p>

View File

@ -7,8 +7,11 @@
-----------------------------------------------------------------------------
-- Declare module and import dependencies
-----------------------------------------------------------------------------
module("socket")
local base = require("base")
local string = require("string")
local math = require("math")
local socket = require("lsocket")
module("socket")
-----------------------------------------------------------------------------
-- Auxiliar functions
@ -40,11 +43,11 @@ socket.try = socket.newtry()
function socket.choose(table)
return function(name, opt1, opt2)
if type(name) ~= "string" then
if base.type(name) ~= "string" then
name, opt1, opt2 = "default", name, opt1
end
local f = table[name or "nil"]
if not f then error("unknown key (" .. tostring(name) .. ")", 3)
if not f then base.error("unknown key (".. base.tostring(name) ..")", 3)
else return f(opt1, opt2) end
end
end
@ -59,7 +62,7 @@ socket.sinkt = {}
socket.BLOCKSIZE = 2048
socket.sinkt["http-chunked"] = function(sock)
return setmetatable({
return base.setmetatable({
getfd = function() return sock:getfd() end,
dirty = function() return sock:dirty() end
}, {
@ -72,7 +75,7 @@ socket.sinkt["http-chunked"] = function(sock)
end
socket.sinkt["close-when-done"] = function(sock)
return setmetatable({
return base.setmetatable({
getfd = function() return sock:getfd() end,
dirty = function() return sock:dirty() end
}, {
@ -86,7 +89,7 @@ socket.sinkt["close-when-done"] = function(sock)
end
socket.sinkt["keep-open"] = function(sock)
return setmetatable({
return base.setmetatable({
getfd = function() return sock:getfd() end,
dirty = function() return sock:dirty() end
}, {
@ -102,7 +105,7 @@ socket.sinkt["default"] = socket.sinkt["keep-open"]
socket.sink = socket.choose(socket.sinkt)
socket.sourcet["by-length"] = function(sock, length)
return setmetatable({
return base.setmetatable({
getfd = function() return sock:getfd() end,
dirty = function() return sock:dirty() end
}, {
@ -119,7 +122,7 @@ end
socket.sourcet["until-closed"] = function(sock)
local done
return setmetatable({
return base.setmetatable({
getfd = function() return sock:getfd() end,
dirty = function() return sock:dirty() end
}, {
@ -137,7 +140,7 @@ socket.sourcet["until-closed"] = function(sock)
end
socket.sourcet["http-chunked"] = function(sock)
return setmetatable({
return base.setmetatable({
getfd = function() return sock:getfd() end,
dirty = function() return sock:dirty() end
}, {
@ -145,7 +148,7 @@ socket.sourcet["http-chunked"] = function(sock)
-- get chunk size, skip extention
local line, err = sock:receive()
if err then return nil, err end
local size = tonumber(string.gsub(line, ";.*", ""), 16)
local size = base.tonumber(string.gsub(line, ";.*", ""), 16)
if not size then return nil, "invalid chunk size" end
-- was it the last chunk?
if size <= 0 then
@ -168,3 +171,5 @@ end
socket.sourcet["default"] = socket.sourcet["until-closed"]
socket.source = socket.choose(socket.sourcet)
base.setmetatable(socket, nil)

View File

@ -23,7 +23,7 @@ http.TIMEOUT = 10
local t = socket.gettime()
host = host or "diego.student.princeton.edu"
proxy = proxy or "http://dell-diego.cs.princeton.edu:3128"
proxy = proxy or "http://localhost:3128"
prefix = prefix or "/luasocket-test"
cgiprefix = cgiprefix or "/luasocket-test-cgi"
index_file = "test/index.html"