diff -ur sockets-1.0.7-orig/src/Makefile sockets-1.0.7/src/Makefile
--- sockets-1.0.7-orig/src/Makefile	2009-08-27 18:23:57 +0100
+++ sockets-1.0.7/src/Makefile	2012-02-09 14:29:07 +0000
@@ -3,9 +3,9 @@
 
 #See which octave version we run by querying mkoctfile for its version
 #string. (Is there a better way to do this? This looks horrible.) 
-majorversion :=$(shell mkoctfile --version 2>&1 |sed -e 's/^.* \([0-9]*\)\.\([0-9]*\).\([0-9]*\)$$/\1/g')
-minorversion:=$(shell mkoctfile --version 2>&1 |sed -e 's/^.* \([0-9]*\)\.\([0-9]*\).\([0-9]*\)$$/\2/g')
-microversion:=$(shell mkoctfile --version 2>&1 |sed -e 's/^.* \([0-9]*\)\.\([0-9]*\).\([0-9]*\)$$/\3/g')
+majorversion :=$(shell mkoctfile --version 2>&1 |sed -e 's/^.* \([0-9]*\)\.\([0-9]*\).\([0-9]*\).*$$/\1/g')
+minorversion:=$(shell mkoctfile --version 2>&1 |sed -e 's/^.* \([0-9]*\)\.\([0-9]*\).\([0-9]*\).*$$/\2/g')
+microversion:=$(shell mkoctfile --version 2>&1 |sed -e 's/^.* \([0-9]*\)\.\([0-9]*\).\([0-9]*\).*$$/\3/g')
 
 VFLAGS=-DMAJORVERSION=$(majorversion) 
 VFLAGS+=-DMINORVERSION=$(minorversion)
@@ -14,7 +14,7 @@
 all: $(OCT)
 
 %.oct: %.cc
-	mkoctfile $(VFLAGS) -s $<
+	mkoctfile $(VFLAGS) -s $< -lws2_32
 
 test: $(OCT)
 	test_octave_sockets
diff -ur sockets-1.0.7-orig/src/sockets.cc sockets-1.0.7/src/sockets.cc
--- sockets-1.0.7-orig/src/sockets.cc	2011-02-20 08:50:35 +0000
+++ sockets-1.0.7/src/sockets.cc	2012-02-09 14:28:07 +0000
@@ -38,6 +38,9 @@
 #include <unistd.h>
 #endif
 #else
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
 typedef unsigned int socklen_t;
 #endif
 #include <errno.h>
@@ -254,8 +257,10 @@
 
 // PKG_ADD: autoload ("MSG_PEEK", "sockets.oct");
 DEFUN_DLD_SOCKET_CONSTANT(MSG_PEEK, "socket constant" );
+#ifdef MSG_DONTWAIT
 // PKG_ADD: autoload ("MSG_DONTWAIT", "sockets.oct");
 DEFUN_DLD_SOCKET_CONSTANT(MSG_DONTWAIT, "socket constant" );
+#endif
 // PKG_ADD: autoload ("MSG_WAITALL", "sockets.oct");
 DEFUN_DLD_SOCKET_CONSTANT(MSG_WAITALL, "socket constant" );
 
