[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaSocket - non-blocking connect ?
- From: "Francisco Sant'anna" <francisco.santanna@...>
- Date: Sun, 31 May 2009 16:10:28 -0300
Hello,
I'm trying the following code, which never prints "after".
I use the sample echo server in the LuaSocket reference.
local recvt, sendt = {}, {}
local master = socket.tcp()
master:settimeout(0)
local obj = master:connect("localhost", 37500)
assert(obj == nil)
print'before'
socket.select(recvt, sendt)
print'after'
If I try the synchronous approach, it works ok, printing "hello".
local obj = socket.connect("localhost", 37500)
obj:send'hello\n'
print(obj:receive())
Thanks,
Francisco
Doing socket.tcp(), setting it to non-blocking, then call connect(),
then selecting on it should work if I recall correctly.
Even if you don't want to use COPAS, it's code is short, and reading
it would give you some decent sample code.
Cheers,
Sam