diff --git a/src/xpdev/multisock.c b/src/xpdev/multisock.c
index 0fae431306e155a1b42155fdabd97978c31cfc9b..3b1dd9f47c25b20298dab0a662acf39bfe4fc3ca 100644
--- a/src/xpdev/multisock.c
+++ b/src/xpdev/multisock.c
@@ -7,6 +7,17 @@
 #include <sockwrap.h>
 #include <multisock.h>
 
+#ifdef _WIN32
+#undef socklen_t
+#include <ws2tcpip.h>
+# ifndef AI_ADDRCONFIG
+#  define AI_ADDRCONFIG 0x400 // Vista or later
+# endif
+# ifndef AI_NUMERICSERV
+#  define AI_NUMERICSERV 0		// Not supported by Win32
+# endif
+#endif
+
 struct xpms_set *xpms_create(unsigned int retries, unsigned int wait_secs,
 	int (*lprintf)(int level, const char *fmt, ...))
 {
diff --git a/src/xpdev/sockwrap.c b/src/xpdev/sockwrap.c
index c386fb0e9143349c8a22d30603ffbf7a89c4e8c2..7f453266d2fd951b1c22a48c7fb0ad23db6f28d4 100644
--- a/src/xpdev/sockwrap.c
+++ b/src/xpdev/sockwrap.c
@@ -42,6 +42,8 @@
 #include <stdio.h>		/* SEEK_SET */
 #include <string.h>
 #if defined(_WIN32)
+ #undef socklen_t
+ #include <ws2tcpip.h>
  #include <malloc.h>	/* alloca() on Win32 */
 #endif