win client use platform invalid socket

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2015-11-14 07:35:27 +08:00
parent 35fef0534b
commit c53f7cad97
3 changed files with 8 additions and 3 deletions

View file

@ -136,7 +136,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
freeaddrinfo(result);
}
if (wsi->sock < 0) {
if (!lws_socket_is_valid(wsi->sock)) {
#ifdef LWS_USE_IPV6
if (LWS_IPV6_ENABLED(context))
@ -145,7 +145,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
#endif
wsi->sock = socket(AF_INET, SOCK_STREAM, 0);
if (wsi->sock < 0) {
if (!lws_socket_is_valid(wsi->sock)) {
lwsl_warn("Unable to open socket\n");
goto oom4;
}

View file

@ -71,6 +71,8 @@
amount = _amount; \
}
#define lws_set_blocking_send(wsi) wsi->sock_send_blocking = TRUE
#define lws_socket_is_valid(x) (!!x)
#define LWS_SOCK_INVALID 0
#include <winsock2.h>
#include <windows.h>
#include <tchar.h>
@ -143,6 +145,8 @@
#define compatible_file_read(amount, fd, buf, len) \
amount = read(fd, buf, len);
#define lws_set_blocking_send(wsi)
#define lws_socket_is_valid(x) (x >= 0)
#define LWS_SOCK_INVALID (-1)
#endif
#ifndef LWS_HAVE_BZERO

View file

@ -618,7 +618,8 @@ libwebsocket_create_new_server_wsi(struct libwebsocket_context *context)
new_wsi->protocol = context->protocols;
new_wsi->user_space = NULL;
new_wsi->ietf_spec_revision = 0;
new_wsi->sock = LWS_SOCK_INVALID;
/*
* outermost create notification for wsi
* no user_space because no protocol selection