LuaSocket: Network support for the Lua language
Description: The LuaSocket Homepage
Keywords: Lua, LuaSocket, Network, Library, Support, Internet

Network support for the Lua language

home · download · installation · introduction · reference

## What is LuaSocket?

LuaSocket is a Lua extension library that is composed by two parts: a C core that provides support for the TCP and UDP transport layers, and a set of Lua modules that add support for functionality commonly needed by applications that deal with the Internet.

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.

Among the support modules, the most commonly used implement the SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading files) client protocols. These provide a very natural and generic interface to the functionality defined by each protocol. In addition, you will find that the MIME (common encodings), URL (anything you could possible want to do with one) and LTN12 (filters, sinks, sources and pumps) modules can be very handy.

The library is available under the same terms and conditions as the Lua language, the MIT license. The idea is that if you can use Lua in a project, you should also be able to use LuaSocket.

Copyright © 2004-2007 Diego Nehab. All rights reserved.
Author: Diego Nehab

## Download

LuaSocket version 2.0.2 is now available for download! It is compatible with Lua 5.1, and has been tested on Windows XP, Linux, and Mac OS X. Chances are it works well on most UNIX distributions and Windows flavors.

The library can be downloaded in source code from the LuaSocket project page 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.

Danilo Tuler is maintaining Win32 binaries for LuaSocket, which are also available from LuaForge. These are compatible with the LuaBinaries, also available from LuaForge.

Take a look at the installation section of the manual to find out how to properly install the library.

## Special thanks

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. Mike Pall has been helping a lot too! Thanks to you all!

## What's New

2.0.2 is just a bug-fix/update release.

- Improved: http.request() now supports deprecated HTTP/0.9 servers (Florian Berger);
- Fixed: could return "timedout" instead of "timeout" (Leo Leo);
- Fixed: crash when reading '*a' on closed socket (Paul Ducklin);
- Fixed: return values are consistent when reading from closed sockets;
- Fixed: case sensitivity in headers of multipart messages in smtp.message() (Graham Henstridge);
- Fixed a couple instances of error() being called instead of base.error(). These would cause an error when an error was reported :) (Ketmar Dark);
- Fixed: test script now uses pairs() iterator instead of the old Lua syntax (Robert Dodier).

2.0.1 is just a bug-fix/update release.

- Updated: now using `compat-5.1r5`;
- Improved: `http.request` is more robust to malformed URLs (Adrian Sietsma);
- Improved: the simple `http.request` interface sends a "`Content-type: application/x-www-form-urlencoded`" header (William Trenker);
- Improved: `http.request` is robust to evil servers that send inappropriate 100-continue messages (David Burgess);
- Fixed: `http.request` was using the old host header during redirects (Florian Berger);
- Fixed: sample `unix.c` had fallen through the cracks during development (Matthew Percival);
- Fixed: error code was not being propagated correctly in ftp.lua (David Burgess).

## Old Versions

All previous versions of the LuaSocket library can be downloaded here. Although these versions are no longer supported, they are still available for those that have compatibility issues.