diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index f1b68c94437..e5d850cb3bc 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1267,8 +1267,13 @@ PySocketSock_connect_ex(PySocketSockObject *s, PyObject *addro) Py_BEGIN_ALLOW_THREADS res = connect(s->sock_fd, addr, addrlen); Py_END_ALLOW_THREADS - if (res != 0) + if (res != 0) { +#ifdef MS_WINDOWS + res = WSAGetLastError(); +#else res = errno; +#endif + } return PyInt_FromLong((long) res); }