Fixed compilation on Windows.
diff --git a/lib/client.c b/lib/client.c
index aa70bfe..c3fb2e8 100644
--- a/lib/client.c
+++ b/lib/client.c
@@ -841,7 +841,11 @@
/* prepare the expected server accept response */
+#ifdef WIN32
+ n = _snprintf(buf, sizeof(buf), "%s%s", key_b64, magic_websocket_guid);
+#else
n = snprintf(buf, sizeof(buf), "%s%s", key_b64, magic_websocket_guid);
+#endif
buf[sizeof(buf) - 1] = '\0';
SHA1((unsigned char *)buf, n, (unsigned char *)hash);
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 3889fdf..c905d83 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -24,6 +24,7 @@
#ifdef WIN32
#include <tchar.h>
#include <io.h>
+#include <mstcpip.h>
#else
#ifdef LWS_BUILTIN_GETIFADDRS
#include <getifaddrs.h>
@@ -572,7 +573,18 @@
* didn't find a way to set these per-socket, need to
* tune kernel systemwide values
*/
+#elif WIN32
+ {
+ DWORD dwBytesRet;
+ struct tcp_keepalive alive;
+ alive.onoff = TRUE;
+ alive.keepalivetime = context->ka_time;
+ alive.keepaliveinterval = context->ka_interval;
+ if (WSAIoctl(fd, SIO_KEEPALIVE_VALS, &alive, sizeof(alive),
+ NULL, 0, &dwBytesRet, NULL, NULL))
+ return 1;
+ }
#else
/* set the keepalive conditions we want on it too */
optval = context->ka_time;
@@ -2053,10 +2065,10 @@
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
- if (info->interface == NULL)
+ if (info->iface == NULL)
serv_addr.sin_addr.s_addr = INADDR_ANY;
else
- interface_to_sa(info->interface, &serv_addr,
+ interface_to_sa(info->iface, &serv_addr,
sizeof(serv_addr));
serv_addr.sin_port = htons(info->port);
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index ffa4896..d3b5215 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -771,7 +771,7 @@
struct lws_context_creation_info {
int port;
- const char *interface;
+ const char *iface;
struct libwebsocket_protocols *protocols;
struct libwebsocket_extension *extensions;
const char *ssl_cert_filepath;
diff --git a/lib/server-handshake.c b/lib/server-handshake.c
index 2feca06..ba52037 100644
--- a/lib/server-handshake.c
+++ b/lib/server-handshake.c
@@ -56,7 +56,13 @@
goto bail;
}
- n = snprintf((char *)context->service_buffer,
+ // TODO: Use a truly platform independent snprintf implementation isntead! http://www.ijs.si/software/snprintf/ maybe?
+ #ifdef WIN32
+ n = _snprintf(
+ #else
+ n = snprintf(
+ #endif
+ (char *)context->service_buffer,
sizeof(context->service_buffer),
"%s258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
lws_hdr_simple_ptr(wsi, WSI_TOKEN_KEY));
diff --git a/lib/server.c b/lib/server.c
index 1b10a86..3e81290 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -374,3 +374,4 @@
}
return 0;
}
+
diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html
index 5b05c36..a07df43 100644
--- a/libwebsockets-api-doc.html
+++ b/libwebsockets-api-doc.html
@@ -971,7 +971,6 @@
<h2>struct lws_context_creation_info - </h2>
<b>struct lws_context_creation_info</b> {<br>
<i>int</i> <b>port</b>;<br>
- <i>const char *</i> <b>interface</b>;<br>
<i>struct libwebsocket_protocols *</i> <b>protocols</b>;<br>
<i>struct libwebsocket_extension *</i> <b>extensions</b>;<br>
<i>const char *</i> <b>ssl_cert_filepath</b>;<br>
@@ -991,9 +990,6 @@
<dd>Port to listen on... you can use 0 to suppress listening on
any port, that's what you want if you are not running a
websocket server at all but just using it as a client
-<dt><b>interface</b>
-<dd>NULL to bind the listen socket to all interfaces, or the
-interface name, eg, "eth2"
<dt><b>protocols</b>
<dd>Array of structures listing supported protocols and a protocol-
specific callback for each one. The list is ended with an
diff --git a/test-server/test-fraggle.c b/test-server/test-fraggle.c
index cfd0f7a..5137711 100644
--- a/test-server/test-fraggle.c
+++ b/test-server/test-fraggle.c
@@ -244,7 +244,7 @@
struct libwebsocket_context *context;
int opts = 0;
char interface_name[128] = "";
- const char *interface = NULL;
+ const char *iface = NULL;
struct libwebsocket *wsi;
const char *address;
int server_port = port;
@@ -274,7 +274,7 @@
case 'i':
strncpy(interface_name, optarg, sizeof interface_name);
interface_name[(sizeof interface_name) - 1] = '\0';
- interface = interface_name;
+ iface = interface_name;
break;
case 'c':
client = 1;
@@ -298,7 +298,7 @@
}
info.port = server_port;
- info.interface = interface;
+ info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
info.extensions = libwebsocket_internal_extensions;
diff --git a/test-server/test-server.c b/test-server/test-server.c
index 388303e..862124d 100644
--- a/test-server/test-server.c
+++ b/test-server/test-server.c
@@ -506,7 +506,7 @@
struct libwebsocket_context *context;
int opts = 0;
char interface_name[128] = "";
- const char *interface = NULL;
+ const char *iface = NULL;
#ifndef WIN32
int syslog_options = LOG_PID | LOG_PERROR;
#endif
@@ -546,7 +546,7 @@
case 'i':
strncpy(interface_name, optarg, sizeof interface_name);
interface_name[(sizeof interface_name) - 1] = '\0';
- interface = interface_name;
+ iface = interface_name;
break;
case 'c':
close_testing = 1;
@@ -598,7 +598,7 @@
}
#endif
- info.interface = interface;
+ info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
info.extensions = libwebsocket_internal_extensions;