--- a/tests/testutil.cpp
+++ b/tests/testutil.cpp
@@ -386,7 +386,7 @@ fd_t connect_socket (const char *endpoint_, const int af_, const int protocol_)
                                protocol_ == IPPROTO_UDP
                                  ? IPPROTO_UDP
                                  : protocol_ == IPPROTO_TCP ? IPPROTO_TCP : 0);
-    TEST_ASSERT_NOT_EQUAL (-1, s_pre);
+    TEST_ASSERT_NOT_EQUAL (retired_fd, s_pre);

     if (af_ == AF_INET || af_ == AF_INET6) {
         const char *port = strrchr (endpoint_, ':') + 1;
@@ -443,7 +443,7 @@ fd_t bind_socket_resolve_port (const char *address_,
                                protocol_ == IPPROTO_UDP
                                  ? IPPROTO_UDP
                                  : protocol_ == IPPROTO_TCP ? IPPROTO_TCP : 0);
-    TEST_ASSERT_NOT_EQUAL (-1, s_pre);
+    TEST_ASSERT_NOT_EQUAL (retired_fd, s_pre);

     if (af_ == AF_INET || af_ == AF_INET6) {
 #ifdef ZMQ_HAVE_WINDOWS

--- a/tests/testutil.hpp
+++ b/tests/testutil.hpp
@@ -102,7 +102,6 @@ const uint8_t zmtp_ready_sub[27] = {
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #include <stdexcept>
-#define close closesocket
 typedef int socket_size_t;
 inline const char *as_setsockopt_opt_t (const void *opt)
 {

--- a/tests/testutil.cpp
+++ b/tests/testutil.cpp
@@ -300,7 +300,7 @@ int is_ipv6_available ()
                 ipv6 = 0;
         }
 #endif
-        close (fd);
+        closesocket (fd);
     }

     return ipv6;
@@ -488,7 +488,7 @@ fd_t bind_socket_resolve_port (const char *address_,
 #else
         int fd = mkstemp (buffer);
         TEST_ASSERT_TRUE (fd != -1);
-        close (fd);
+        closesocket (fd);
 #endif
 #endif
         strcpy ((*(struct sockaddr_un *) &addr).sun_path, buffer);
