diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 8c743d8..3ae600e 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -351,16 +351,13 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); static SOCKET dup_socket(SOCKET handle) { - HANDLE newhandle; + WSAPROTOCOL_INFO info; - if (!DuplicateHandle(GetCurrentProcess(), (HANDLE)handle, - GetCurrentProcess(), &newhandle, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - { - WSASetLastError(GetLastError()); + if (WSADuplicateSocket(handle, GetCurrentProcessId(), &info)) return INVALID_SOCKET; - } - return (SOCKET)newhandle; + + return WSASocket(info.iAddressFamily, info.iSocketType, + info.iProtocol, &info, 0, 0); } #define SOCKETCLOSE closesocket #else