diff --git a/src/i_tcp.c b/src/i_tcp.c
index e20e43ea44354e878116a8ba9e786201233caff2..4738b9df8175a26c1cca2c97202e3046e08e04da 100644
--- a/src/i_tcp.c
+++ b/src/i_tcp.c
@@ -50,9 +50,6 @@
 	#else
 		#ifndef USE_WINSOCK
 			#include <arpa/inet.h>
-		#endif //normal BSD API
-
-		#ifndef USE_WINSOCK
 			#ifdef __APPLE_CC__
 				#ifndef _BSD_SOCKLEN_T_
 					#define _BSD_SOCKLEN_T_
@@ -60,9 +57,6 @@
 			#endif //__APPLE_CC__
 			#include <sys/socket.h>
 			#include <netinet/in.h>
-		#endif //normal BSD API
-
-		#ifndef USE_WINSOCK
 			#include <netdb.h>
 			#include <sys/ioctl.h>
 		#endif //normal BSD API
diff --git a/src/mserv.c b/src/mserv.c
index 58fb36bcbb1dff57d9dd860726a7f803979c83a2..84fdca80ed3c079e697c8efcdf9ac461812b0f82 100644
--- a/src/mserv.c
+++ b/src/mserv.c
@@ -22,6 +22,19 @@
 	#define NONET
 #endif
 
+#ifndef NO_IPV6
+	#define HAVE_IPV6
+#endif
+
+#ifdef _WIN32
+	#define USE_WINSOCK
+	#if /*defined (_WIN64) ||*/ defined (HAVE_IPV6)
+		#define USE_WINSOCK2
+	#else //_WIN64/HAVE_IPV6
+		#define USE_WINSOCK1
+	#endif
+#endif //WIN32 OS
+
 #ifndef NONET
 	#ifndef NO_IPV6
 		#define HAVE_IPV6
@@ -196,7 +209,7 @@ typedef unsigned long SOCKET_TYPE;
 #define ERRSOCKET (-1)
 #endif
 
-#if (defined (WATTCP) && !defined (__libsocket_socklen_t)) || defined (_WIN32)
+#if (defined (WATTCP) && !defined (__libsocket_socklen_t)) || defined (USE_WINSOCK1)
 typedef int socklen_t;
 #endif