diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-08-06 22:25:02 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-08-06 22:25:02 (GMT) |
commit | 5814187f5b4d1a956c9719de1538865694677b55 (patch) | |
tree | 0bb6b7255bda1134601e88603a8e58b279700534 | |
parent | d37f75b88a5a861912a18f47ea993a861fb167fe (diff) | |
download | cpython-5814187f5b4d1a956c9719de1538865694677b55.zip cpython-5814187f5b4d1a956c9719de1538865694677b55.tar.gz cpython-5814187f5b4d1a956c9719de1538865694677b55.tar.bz2 |
internal_connect(): Windows. When sock_timeout > 0 and connect() yields
WSAEWOULDBLOCK, the second connect() attempt appears to yield WSAEISCONN
on Win98 but WSAEINVAL on Win2K. So accept either as meaning "yawn,
fine". This allows test_socket to succeed on my Win2K box (which it
already did on my Win98SE box).
-rw-r--r-- | Modules/socketmodule.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index b9358b7..a540a2a 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1305,8 +1305,16 @@ internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen) if (res < 0 && WSAGetLastError() == WSAEWOULDBLOCK) { internal_select(s, 1); res = connect(s->sock_fd, addr, addrlen); - if (res < 0 && WSAGetLastError() == WSAEISCONN) - res = 0; + if (res < 0) { + /* On Win98, WSAEISCONN was seen here. But + * on Win2K, WSAEINVAL. So accept both as + * meaning "fine". + */ + int code = WSAGetLastError(); + if (code == WSAEISCONN || + code == WSAEINVAL) + res = 0; + } } } @@ -2495,11 +2503,11 @@ socket_ntohl(PyObject *self, PyObject *arg) return PyErr_Format(PyExc_OverflowError, "long int larger than 32 bits"); x = y; - } + } #endif } else - return PyErr_Format(PyExc_TypeError, + return PyErr_Format(PyExc_TypeError, "expected int/long, %s found", arg->ob_type->tp_name); if (x == (unsigned long) -1 && PyErr_Occurred()) @@ -2554,11 +2562,11 @@ socket_htonl(PyObject *self, PyObject *arg) return PyErr_Format(PyExc_OverflowError, "long int larger than 32 bits"); x = y; - } + } #endif } else - return PyErr_Format(PyExc_TypeError, + return PyErr_Format(PyExc_TypeError, "expected int/long, %s found", arg->ob_type->tp_name); return PyInt_FromLong(htonl(x)); |