diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 7ebc0f694..65efd7e65 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -20,7 +20,11 @@
  */
 
 #include "private-libwebsockets.h"
+
+#ifndef _WIN32_WCE
 #include <sys/types.h>
+#endif
+
 #if defined(WIN32) || defined(_WIN32)
 #else
 #include <sys/wait.h>
diff --git a/lib/lws-plat-win.c b/lib/lws-plat-win.c
index cec976668..428ae7cd1 100644
--- a/lib/lws-plat-win.c
+++ b/lib/lws-plat-win.c
@@ -271,7 +271,10 @@ lws_plat_set_socket_options(struct lws_context *context, lws_sockfd_type fd)
 	u_long optl = 1;
 	DWORD dwBytesRet;
 	struct tcp_keepalive alive;
+	int protonbr;
+#ifndef _WIN32_WCE
 	struct protoent *tcp_proto;
+#endif
 
 	if (context->ka_time) {
 		/* enable keepalive on this socket */
@@ -293,15 +296,16 @@ lws_plat_set_socket_options(struct lws_context *context, lws_sockfd_type fd)
 	optval = 1;
 #ifndef _WIN32_WCE
 	tcp_proto = getprotobyname("TCP");
-#else
-	tcp_proto = 6;
-#endif
 	if (!tcp_proto) {
 		lwsl_err("getprotobyname() failed with error %d\n", LWS_ERRNO);
 		return 1;
 	}
+	protonbr = tcp_proto->p_proto;
+#else
+	protonbr = 6;
+#endif
 
-	setsockopt(fd, tcp_proto->p_proto, TCP_NODELAY, (const char *)&optval, optlen);
+	setsockopt(fd, protonbr, TCP_NODELAY, (const char *)&optval, optlen);
 
 	/* We are nonblocking... */
 	ioctlsocket(fd, FIONBIO, &optl);