From 6c1bc0e2f6d55bcc40081aec5c543c613185ab3e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 6 Jan 2015 20:12:09 -0600 Subject: [PATCH] sync ws code --- libs/sofia-sip/libsofia-sip-ua/tport/ws.c | 9 +++++++-- libs/sofia-sip/libsofia-sip-ua/tport/ws.h | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 51ae0f13f7..db2e39e5ab 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c @@ -309,7 +309,7 @@ int ws_handshake(wsh_t *wsh) "%s\r\n", b64, proto_buf); - + respond[511] = 0; ws_raw_write(wsh, respond, strlen(respond)); wsh->handshake = 1; @@ -322,6 +322,7 @@ int ws_handshake(wsh_t *wsh) snprintf(respond, sizeof(respond), "HTTP/1.1 400 Bad Request\r\n" "Sec-WebSocket-Version: 13\r\n\r\n"); + respond[511] = 0; ws_raw_write(wsh, respond, strlen(respond)); @@ -399,7 +400,7 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block) ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes) { - size_t r; + ssize_t r; int sanity = 2000; int ssl_err = 0; @@ -656,7 +657,11 @@ ssize_t ws_close(wsh_t *wsh, int16_t reason) restore_socket(wsh->sock); if (wsh->close_sock && wsh->sock != ws_sock_invalid) { +#ifndef WIN32 close(wsh->sock); +#else + closesocket(wsh->sock); +#endif } wsh->sock = ws_sock_invalid; diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h index 7f5f5c48b4..1dd85a5d93 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h @@ -11,11 +11,11 @@ #include #include #include +#include #else #pragma warning(disable:4996) #endif #include -#include #include #include #include @@ -26,7 +26,9 @@ #include #ifdef _MSC_VER +#ifndef strncasecmp #define strncasecmp _strnicmp +#endif #define snprintf _snprintf #ifdef _WIN64 #define WS_SSIZE_T __int64 @@ -48,8 +50,12 @@ struct ws_globals_s { extern struct ws_globals_s ws_globals; +#ifndef WIN32 typedef int ws_socket_t; -#define ws_sock_invalid -1 +#else +typedef SOCKET ws_socket_t; +#endif +#define ws_sock_invalid (ws_socket_t)-1 typedef enum {