The following code does not work correctly on Windows (but does on Linux): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)