aboutsummaryrefslogtreecommitdiff
path: root/doc/index.html
blob: 06369a76c8cee8d2f8316f29fe290cb9ae659696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!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="home.html">home</a> &middot;
<a href="home.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; 2004-2005 Diego Nehab. All rights reserved. <br>
Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a>
</p>

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

<h2 id=download>Download</h2>

<p>
LuaSocket version  2.0 (final) 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>

<p>
The library can be downloaded in source code from the
<a href=http://luaforge.net/projects/luasocket/>LuaSocket
project page</a> at LuaForge. 
Besides the full C and Lua source code for the library, the distribution
contains several examples, this user's manual and basic test procedures.
</p>

<p>
Danilo Tuler is maintaining Win32 binaries for LuaSocket, which are also
available from LuaForge.  These are compatible with the 
<a href=http://luaforge.net/projects/luabinaries>LuaBinaries</a> 
available from LuaForge. 
</p>

<p>
For those that  want to give LuaSocket a quick try, download the
stand-alone archive and unpack everything into
a directory, say <tt>c:\luasocket</tt>. 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 the current directory: 
</p>

<pre class=example>
c:\luasocket\&gt; set LUA_INIT=@c:\luasocket\compat-5.1.lua
c:\luasocket\&gt; set LUA_CPATH=?.dll
c:\luasocket\&gt; set LUA_PATH=?.lua
</pre>

<p>
From that directory, you can then run the interpreter and it should find all
files it needs. To download this manual page from the Internet, for example, 
do the following:
</p>

<pre class=example>
c:\luasocket\&gt; lua50
Lua 5.0.2  Copyright (C) 1994-2004 Tecgraf, PUC-Rio
&gt; http = require"socket.http"
&gt; print(http.request"http://www.cs.princeton.edu/~diego/professional/luasocket/")
--&gt; the source to this web page gets dumped to terminal
</pre>

<p> When you are done playing, 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>
Throughout LuaSocket's history, many people gave suggestions that helped
improve it. For that, I thank the Lua community. 
Special thanks go to
David Burgess, who has helped push the library to a new level of quality and
from whom I have learned a lot of stuff that doesn't show up in RFCs.
Special thanks also to Carlos Cassino, who played a big part in the 
extensible design seen in the C core of LuaSocket 2.0. Recently, Mike Pall
has been helping a lot too! Thanks to you all! 
</p>

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

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

<p>
There is no big change for the 2.0 (final) release. It is basically a 
bug fix release. The only improvement is in the non-blocking 
support. 
</p>

<ul>
<li> New: sample module <tt>dispatch.lua</tt> implements a
coroutine based dispatcher; 
<li> New: sample <tt>check-links.lua</tt> works
both in blocking and non-blocking mode using coroutines
(using the new dispatcher);
<li> New: sample <tt>forward.lua</tt> implements a coroutine
based forward server (using the new dispatcher);
<li> Improved: <tt>tcp:send(data, i, j)</tt> to return <tt>(i+sent-1)</tt>.  This is great for non-blocking I/O, but might break some code;
<li> Improved: HTTP, SMTP, and FTP functions to accept a new field
<tt>create</tt> that overrides the function used to create socket objects;
<li> Improved: <tt>smtp.message</tt> now supports multipart/alternative
(for the HTML messages we all love so much); 
<li> Fixed: <tt>smtp.send</tt> was hanging on errors returned by LTN12 sources;
<li> Fixed: <tt>url.absolute()</tt> to work when <tt>base_url</tt> is in
parsed form;
<li> Fixed: <tt>http.request()</tt> not to redirect when the location 
header is empty (naughty servers...);
<li> Fixed: <tt>tcp{client}:shutdown()</tt> to check for class instead of
group;
<li> Fixed: The manual to stop using <tt>socket.try()</tt> in place of
<tt>assert()</tt>, since it can't; 
<li> Improved: Got rid of <tt>package.loaded.base = _G</tt> kludge;
<li> Fixed: Parts of the manual referred to <tt>require("http")</tt> instead of
<tt>require("socket.http")</tt>;
<li> Improved: Socket and MIME binaries are called 'core' each inside their
directory (ex. "socket/core.dll"). The 'l' prefix was just a bad idea;
<li> Improved: Using bundles in Mac OS X, instead of dylibs; 
<li> Fixed: <tt>luasocket.h</tt> to export <tt>luaopen_socket_core</tt>;
<li> Fixed: <tt>udp:setpeername()</tt> so you can "disconnect" an 
<tt>UDP</tt> socket;
<li> Fixed: A weird bug in HTTP support that caused some requests to 
fail (Florian Berger);
<li> Fixed: Bug in <tt>socket.select()</tt> that caused sockets 
with descriptor 0 to be ignored (Renato Maia);
<li> Fixed: "Bug" that caused <tt>dns.toip()</tt> to crash under uLinux
(William Trenker);
<li> Fixed: "Bug" that caused <tt>gethostbyname</tt> to crash under VMS
(Renato Maia);
<li> Fixed: <tt>tcp:send("")</tt> to return 0 bytes sent (Alexander Marinov);
<li> Improved: <tt>socket.DEBUG</tt> and <tt>socket.VERSION</tt> became <tt>socket._DEBUGs</tt> and <tt>socket._VERSION</tt> for uniformity with other libraries;
<li> Improved: <tt>socket.select</tt> now works on empty sets on Windows. 
</ul>

<!-- incompatible +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

<h3 id=incompatible>Incompatibilities with previous versions</h3>

<ul>
<li> If you use the return value of <tt>tcp:send()</tt> <em>and</em> you
use the extra parameters to select only part of the string to be sent, your
code is now broken, but when you fix it, it will be much simpler;
<li> If you check <tt>socket.DEBUG</tt> or <tt>socket.VERSION</tt>, 
change it to <tt>socket._DEBUG</tt> or <tt>socket._VERSION</tt>.
</ul>

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

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

<p>
All  previous versions  of the  LuaSocket library  can be  downloaded <a
href="http://www.cs.princeton.edu/~diego/professional/luasocket/old">
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="home.html#down">download</a> &middot;
<a href="home.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>
Mon Nov 21 01:56:56 EST 2005
</small>
</p>
</center>
</div>

</body>
</html>