diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 327e470..27996aa 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2270,8 +2270,15 @@ sock_recv_guts(PySocketSockObject *s, char* cbuf, Py_ssize_t len, int flags) BEGIN_SELECT_LOOP(s) Py_BEGIN_ALLOW_THREADS timeout = internal_select_ex(s, 0, interval); - if (!timeout) + if (!timeout) { +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (len > INT_MAX) + len = INT_MAX; + outlen = recv(s->sock_fd, cbuf, (int)len, flags); +#else outlen = recv(s->sock_fd, cbuf, len, flags); +#endif + } Py_END_ALLOW_THREADS if (timeout == 1) { @@ -2477,18 +2484,18 @@ sock_recvfrom_guts(PySocketSockObject *s, char* cbuf, Py_ssize_t len, int flags, memset(&addrbuf, 0, addrlen); timeout = internal_select_ex(s, 0, interval); if (!timeout) { -#ifndef MS_WINDOWS -#if defined(PYOS_OS2) && !defined(PYCC_GCC) +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (len > INT_MAX) + len = INT_MAX; + n = recvfrom(s->sock_fd, cbuf, (int)len, flags, + SAS2SA(&addrbuf), &addrlen); +#elif defined(PYOS_OS2) && !defined(PYCC_GCC) n = recvfrom(s->sock_fd, cbuf, len, flags, SAS2SA(&addrbuf), &addrlen); #else n = recvfrom(s->sock_fd, cbuf, len, flags, (void *) &addrbuf, &addrlen); #endif -#else - n = recvfrom(s->sock_fd, cbuf, len, flags, - SAS2SA(&addrbuf), &addrlen); -#endif } Py_END_ALLOW_THREADS @@ -2692,6 +2699,10 @@ sock_sendall(PySocketSockObject *s, PyObject *args) if (!timeout) { #ifdef __VMS n = sendsegmented(s->sock_fd, buf, len, flags); +#elif defined(MS_WIN64) || defined(MS_WINDOWS) + if (len > INT_MAX) + len = INT_MAX; + n = send(s->sock_fd, buf, (int)len, flags); #else n = send(s->sock_fd, buf, len, flags); #endif @@ -2774,8 +2785,15 @@ sock_sendto(PySocketSockObject *s, PyObject *args) BEGIN_SELECT_LOOP(s) Py_BEGIN_ALLOW_THREADS timeout = internal_select_ex(s, 1, interval); - if (!timeout) + if (!timeout) { +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (len > INT_MAX) + len = INT_MAX; + n = sendto(s->sock_fd, buf, (int)len, flags, SAS2SA(&addrbuf), addrlen); +#else n = sendto(s->sock_fd, buf, len, flags, SAS2SA(&addrbuf), addrlen); +#endif + } Py_END_ALLOW_THREADS if (timeout == 1) {