lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


At 01:46 PM 1/22/2003, you wrote:



* I've looked at several minimal/small-footprint webservers in C, and would like to try to build something similar in Lua. Ideas anybody?


I wrote a 'single threaded' web server written in lua4 that supports running lua scripts as CGI commands. It was written quickly, without a detailed understanding of lua or luasockets, but serves my purposes well.

I'd be willing to release it public domain if the community:

a) doesn't flame me for my poor understanding of lua and the http protocol
b) helps make it better

Perhaps I'm asking too much ;-).

-joe


One problem you might come across is the want to use stat() or similar
(ie, to get date stamps for files so you can put the last modified
header in, and respond to if-modified-since requests).  There isn't a
stat() like thing in ANSI C AFAIK, so you may have do some work in the C
domain anyway, perhaps quite a lot to get acceptable performance.  You
may also run into the problem that you can't select() on normal Lua file handles (I think) which would be great for this, too. Perhaps also a
little sendfile() magic
I think I've found a very good candidate for doinbg the server part in C:
libwebserver (http://libwebserver.sourceforge.net/)

I will try to 'embed' this into Lua, as the setting-up of a 'server' is really very simple:
* init the server (port, logfile)
* register 'handler' function for URL shemes (this is where Lua would come in)
* run the server

The docu,mentation in the tar isclear with good examples,
and most importantly for me, the project builds out-of-the-box on windows (vc6) and linux.

If there is interst I'll post my progress,

-Martin