Fix nonblocking connect on Windows
Use the correct value for the call to ioctlsocket() to set the socket to
nonblocking mode and check for WSAWOULDBLOCK return value of connect().
diff --git a/lib/client-handshake.c b/lib/client-handshake.c
index f80b9b4..2fec991 100644
--- a/lib/client-handshake.c
+++ b/lib/client-handshake.c
@@ -177,7 +177,8 @@
if (connect(wsi->sock, v, n) == -1 || LWS_ERRNO == LWS_EISCONN) {
- if (LWS_ERRNO == LWS_EALREADY || LWS_ERRNO == LWS_EINPROGRESS) {
+ if (LWS_ERRNO == LWS_EALREADY || LWS_ERRNO == LWS_EINPROGRESS
+ || LWS_ERRNO == LWS_EWOULDBLOCK) {
lwsl_client("nonblocking connect retry\n");
/*
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index bb13069..520aa6b 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -694,7 +694,7 @@
int optval = 1;
socklen_t optlen = sizeof(optval);
#if defined(WIN32) || defined(_WIN32)
- unsigned long optl = 0;
+ u_long optl = 1;
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
struct protoent *tcp_proto;