What is LuaSocket?
LuaSocket is a Lua extension library that provides support for TCP and
UDP socket layer within the Lua language. The library also provides
support for SMTP (sending e-mails), HTTP (www) and FTP (uploading and
It can be used by any Lua application desiring access to network
communication on the Internet, once it has been properly linked with and
initialized by the interpreter running the application. The code has
been tested and runs well both on Windows and on Unix Platforms.
The library is available under the same terms as the Lua language, that
is, it can be used at no cost for both academic and commercial purposes.
LuaSocket version 1.2 is now available for download! It is compatible
with Lua 4.0 and has been tested on Windows 98, Windows 2000, Linux,
AIX, and Solaris.
There have been some improvements since version 1.1, mainly motivated by
feedback from the Lua community:
* C Code has been completely rewritten, and is now simpler, faster,
more robust and more complete.
* Added full support for the UDP protocol.
* Host name resolution is much more robust, and new functions toip and
tohostname are provided that perform DNS conversions. Multi-homed hosts
are better supported.
* New functions getsockname and getpeername.
* New function poll allows busy polling of sockets.
* All input from TCP is now buffered. Line I/O is now much faster (10x+
or more). All I/O is now non-blocking, avoiding busy waits by calls
to select to block the process.
* timeout method for the server socket is now supported, and affects
the accept method.
* Global versions of socket methods are now optional at compile time.
The only globals always exported are connect, bind and udpsocket,
toip and tohostname.
* HTTP protocol is now method independent. Http_get and http_post are
provided, but simply call the generic http_request function.
* FTP protocol starts data connection passively using the PORT command.
Even a minimal FTP server will be usable. CWD now changes directory
with a single command, which is faster.
* All memory allocation is performed by the Lua interpreter, and this
leads to better garbage collection performance.
* The manual has been expanded and improved, hopefully.
* Source code comments have been checked.
Incompatibilities with Previous Versions
There server method listen has been removed from the library. The
backlog server socket value, when the default value of 1 is not
satisfactory, MUST be assigned at bind time.
Take a look at the LuaSocket website at