Andreas Krinke wrote:
(Sun, 25 Oct 2009 09:39:44 -0700)

>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).

I'll check that out. Very useful. I also think that TCC might be persuaded to 
compile such that Lua runs without a console. I didn't explore because at the 
time I think it demanded more than I knew. Probably still does but next time I 
look at using TCC I'll try that.

>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

Thanks for that. :) Very fun bit of code! (And especially useful to have the 
same in two forms (This is ideal, it gives lots of possibilities for exploring. 
Only had a look at its output via Firefox for now but I now have something very 
good to do with my time tomorrow. One thing I read yesterday was that Windows 
can have difficulties with socketry that isn't done in the main thread, but as 
far as I know, in wxLua the message loop means event driven conditions allow 
many connections to be handled without multithreading. Is it as simple and 
efficient as it sounds, or am I missing something I need to know at the outset 
before trying things?

One other thing just cropped up.. While I was writing this, I'd left wxLua 
running the above code, and some time after I'd closed Firefox a wxLua error 
message came up stating that variable 'client' had become a nil value when 
indexed on line 15 (client:Read(1)). Any advice on prevention?


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to