[Libwebsockets] [libwebsockets] With new nonblocking socket setting on iOS socket fails on EISCONN (#17)

"Andy Green (林安廸)" andy at warmcat.com
Thu Oct 24 16:39:55 CEST 2013

On 24/10/13 22:22, the mail apparently from shyswork included:
> To tell the truth I'm not that good with sockets and I didn't spend
> enough time to thoroughly investigate your code so I may be wrong.
> Everything I say further is related to iOS. As I understand since socket
> is nonblocking, when we first time try to connect, it returns
> EINPROGRESS which is perfectly fine since it didn't block and returned
> straight away. Then we somehow get again to
> __libwebsocket_client_connect_2 and by that time socket is already
> connected so it says EISCONN which now has to be treated as success.
> When I was testing I used simple check in
> https://github.com/warmcat/libwebsockets/blob/master/lib/client-handshake.c#L104
> if (errno != EISCONN) { lwsl_debug("Connect failed errno=%d\n", errno);
> goto failed; } which then worked fine for me.

That's too scary for me because on Linux, I don't think we'll see it.

I pushed this


which should do a simlar behaviour compatibly, at least I hope it does.

> I also experienced problems with nonblocking sockets which were long
> times to send and receive messages but I can't be sure if it was related
> to nonblocking sockets or to the fact I had problems with
> multithreading. I have fixed my problems with multithreading so I will
> test it again today or tomorrow and write you back.

OK.  AFAIK it should do a really proper nonblocking implementation with 
no spinning.  If we've missed a case somewhere we'd love to know.  If 
you're casually able to reproduce then try and see if you have the same 
problem with the test client and server.


>> Reply to this email directly or view it on GitHub
> <https://github.com/warmcat/libwebsockets/issues/17#issuecomment-26996221>.

More information about the Libwebsockets mailing list