]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
sync ws code
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 7 Jan 2015 02:12:09 +0000 (20:12 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 7 Jan 2015 08:12:29 +0000 (02:12 -0600)
libs/sofia-sip/libsofia-sip-ua/tport/ws.c
libs/sofia-sip/libsofia-sip-ua/tport/ws.h

index 51ae0f13f7a0dbe524c961017f5c8cd5469bcb61..db2e39e5ab58cc60b745db476c0b43f92a509a5a 100644 (file)
@@ -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;
index 7f5f5c48b4a14875a541493b5d0907e89fd33688..1dd85a5d93c13d6fe0dff533b96feae9092036e8 100644 (file)
 #include <arpa/inet.h>
 #include <sys/wait.h> 
 #include <sys/socket.h>
+#include <unistd.h>
 #else
 #pragma warning(disable:4996)
 #endif
 #include <string.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -26,7 +26,9 @@
 #include <openssl/ssl.h>
 
 #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 {