Looks like setting timeout for Lua socket only works after connect, and I can’t use assert (socket.connect (..)), because I have multiple servers to try out.
My scenario is that when one server is down (can’t connect rather than unstable network), I will resort to a different one, so I must have a timeout on connect.
Any suggestions?
EDIT
I found Lua TCP socket, but with that, I was unable to detect connection failure,
local tcp = socket.tcp()
tcp:settimeout(1)
tcp:connect(...)
If it does not work it is probably because your luasocket is too old, update to version 2: