lua-users home
lua-l archive

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


Hi Oliver,

> I could solve (or bypass) the problem by commenting the lines containing the repeat, the until.. and the return ret, err out and set a return 1 instead:

I don't think this is the correct change. The lines are there to try
another "connect" call if there is a timeout: 'if ret or err ~=
"timeout" then'. If the call is successful or any other error is
returned, then the result of skt:connect is returned. What problem are
you trying to solve with your change?

I've seen this not working on Windows in the way I'd expect by reading
the code, as "connect" on Windows doesn't return "timeout", but
returns "Operation already in progress" instead. I applied the same
solution as described here by Jerome Vuarand:
http://lua.2524044.n2.nabble.com/LuaSocket-asynchronous-connect-on-Windows-not-behaving-properly-td3981262.html

Paul.

On Fri, Jul 25, 2014 at 10:42 AM, Oliver Kroth <oliver.kroth@nec-i.de> wrote:
> this issue must have been too difficult, or much too simple...
>
> I guess the latter. I could solve (or bypass) the problem by commenting the
> lines containing the repeat, the until.. and the return ret, err out and set
> a return 1 instead:
>
>> 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
>>     return 1
>> end
>>
>
> Now it works.
> I tell it just in case someone listens to my soliloquy ;-)
>
> --
> Oliver
>
>