A WIN32 SOCKET is a HANDLE type and is not equivalent in size to an 'int'. Windows SOCKET values frequently exceed MAX_INT and become truncated. convert all references to SOCKET and use closesocket() to release the them instead of the C Runtime Library close() which only applies to file descriptors. Proposed patch attached.