From: Andreas K. <and...@gm...> - 2009-10-25 16:39:34
|
lostgallifreyan wrote: > I'm guessing I'll have to compile Lua with LuaSocket but I think I > can do it, I managed to compile my copies of v5.1.4 Lua and Luac and > Lua.dll with TCC compiler, so that could be a nice way to go. On the > other hand, that means console windows popping up, and for something > like a web proxy based filter system it's nice if it runs very much > in the background. If I try both I'll learn more though. You should be able to use binaries for Lua [1]. In the Lua for Windows package there is a wlua.exe that doesn't pop up a console window (if I remember correctly). [1] http://luabinaries.luaforge.net/index.html Here is the same example implemented using wxLua: function Main() local ip = wx.wxIPV4address() -- localhost print(ip:AnyAddress()) print(ip:Service(8080)) local socket = wx.wxSocketServer(ip, wx.wxSOCKET_WAITALL) print(socket:Ok()) local data while 1 do data = {} print("waiting...") local client = socket:Accept(true) repeat data[#data+1] = client:Read(1) until data[#data] == "\n" print(table.concat(data)) client:Write([[ <html> <body> <h1>wxLua Proxy Test</h1> </body> </html> ]]) client:Close() end end |