/* 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);
#ifdef WIN32
#include <tchar.h>
#include <io.h>
+#include <mstcpip.h>
#else
#ifdef LWS_BUILTIN_GETIFADDRS
#include <getifaddrs.h>
* 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;
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);
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;
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));
<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>
<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
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;
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;
}
info.port = server_port;
- info.interface = interface;
+ info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
info.extensions = libwebsocket_internal_extensions;
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
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;
}
#endif
- info.interface = interface;
+ info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
info.extensions = libwebsocket_internal_extensions;