lua-users home
lua-l archive

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


----------------------------------------
> Date: Thu, 15 Oct 2009 10:21:53 -0700
> Subject: Re: Using LuaSocket with non-blocking sockets
> From: vieuxtech@gmail.com
> To: lua@bazar2.conectiva.com.br
>
> On Sun, Oct 11, 2009 at 5:28 PM, Jonathan Castello wrote:
> > I'm using non-blocking sockets with LuaSocket under Win32, and I find myself looking for a way to tell if a connect() call failed. I can use socket.select(nil, {sock}, 0) to see if the socket has connected successfully, but I don't see any way to tell if it failed. Looking over the WinSock documentation, I notice an 'exceptfds' parameter that comes after the read and write tables, but LuaSocket doesn't appear to use it at all (its source shows NULL used instead). The WinSock documentation says that if a nonblocking socket failed to connect, passing it in as part of 'exceptfds' would return the socket as part of that list.
>
> I doubt that that winsocket works like that, it would be completely
> incompatible with the BSD socket API.
>
> You're not the first one to be confused by the documentaion, though,
> "exception" in this case doesn't mean "error", it means "exceptional
> data", which with TCP means "out-of-band data is pending on the
> socket". OOB data isn't commonly used outside of older unix protocols
> like rsh, and telnet.
>


The WinSock page in this case (http://msdn.microsoft.com/en-us/library/ms740141(VS.85).aspx) specifically says this:

exceptfds:
- If processing a connect call (nonblocking), connection attempt failed.
- OOB data is available for reading (only if SO_OOBINLINE is disabled).

Looking over the man page you linked me, it doesn't seem like Linux does it this way, which is interesting. From what I'm hearing, it looks like I will need to send a no-op to determine if it failed or is just still connecting?

~Jonathan Castello


Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. Sign up now.