Message17330
The socketmodule.c code does not handle connection
refused correctly. This is due to a different of
operation on windows of select. The offending code is
in internal_connect in the MS_WINDOWS ifdef. The code
in should test exceptfds to check for connecttion
refused. If this is so itshould call
getsockopt(SOL_SOCKET, SO_ERROR,..) to get the error
status. (Source microsoft Platform SDK)
The suggested fix is shown below (untested)
#ifdef MS_WINDOWS
f (s->sock_timeout > 0.0) {
if (res < 0 && WSAGetLastError() == WSAEWOULDBLOCK) {
/* This is a mess. Best solution: trust select */
fd_set exfds;
struct timeval tv;
tv.tv_sec = (int)s->sock_timeout;
tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6);
FD_ZERO(&exfds);
FD_SET(s->sock_fd, &exfds);
/* Platform SDK says so */
res = select(s->sock_fd+1, NULL, NULL, &exfds, &tv);
if (res > 0) {
if( FD_ISSET( &exfds ) ) {
/* Get the real reason */
getsockopt(s->sock_fd,SOL_SOCKET,SO_ERROR,(char*)&res,sizeof(res));
} else {
/* God knows how we got here */
res = 0;
}
} else if( res == 0 ) {
res = WSAEWOULDBLOCK;
} else
{
/* Not sure we should return the erro from select? */
res = WSAGetLastError();
}
}
} else if (res < 0)
res = WSAGetLastError();
#else |
|
Date |
User |
Action |
Args |
2007-08-23 14:15:19 | admin | link | issue777597 messages |
2007-08-23 14:15:19 | admin | create | |
|