cpython: c59d81b802f8 (original) (raw)

--- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2299,7 +2299,8 @@ sock_setsockopt(PySocketSockObject *s, P if (PyArg_ParseTuple(args, "iii:setsockopt", &level, &optname, &flag)) {

@@ -2450,7 +2451,17 @@ static int internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen, int *timeoutp) {

+#ifdef MS_WINDOWS +# define GET_ERROR WSAGetLastError() +# define IN_PROGRESS_ERR WSAEWOULDBLOCK +# define TIMEOUT_ERR WSAEWOULDBLOCK +#else +# define GET_ERROR errno +# define IN_PROGRESS_ERR EINPROGRESS +# define TIMEOUT_ERR EWOULDBLOCK +#endif +

timeout = 0; @@ -2458,105 +2469,45 @@ internal_connect(PySocketSockObject *s, res = connect(s->sock_fd, addr, addrlen); Py_END_ALLOW_THREADS -#ifdef MS_WINDOWS - if (res < 0)

-

-

-

-

+

+

-

-

- -#else

-

-

-

- -#endif

/* s.connect(sockaddr) method */