[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: copas.connect() repeats skt:connect()....why?
- From: Oliver Kroth <oliver.kroth@...>
- Date: Wed, 23 Jul 2014 10:07:20 +0200
Hello,
I am currently trying to get a Lua script working that uses COPAS with
client sockets, i.e. it does a copas.connect() call.
The underlying OS tells me that the socket is opened twice: once with
the result "timeout" which is perfect, but later again, and then it fails.
The code in copas looks like this:
function copas.connect(skt, host, port)
skt:settimeout(0)
local ret, err
repeat
ret, err = skt:connect (host, port)
if ret or err ~= "timeout" then
_writing_log[skt] = nil
return ret, err
end
_writing_log[skt] = gettime()
coroutine.yield(skt, _writing)
until false
return ret, err
end
One can see that there is a repeat-until loop around the skt:connect()
As far as I know, the "standard" method to connect a non.blocking socket
is to call connect() and then do a select() to find out when it is
writeable.
Possibly the above method works under Linux, etc. but it does not work
with the OS I have to use. The second skt:connect() fails with an error
telling me that the socket has an illegal handle (possibly because it is
not a not yet connect()-ed socket).
Does anyone have a hint?
--
Oliver