X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/686d0cc0a6251b9823c271ba615186daa0d8e7fd..2e14066008229145e2da7b9f05a478ce38631f83:/src/common/socket.cpp diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 64803df7a4..36a9dc1090 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -1297,17 +1297,31 @@ wxSocketEventFlags wxSocketImpl::Select(wxSocketEventFlags flags, exceptfds; // always want to know about errors if ( flags & wxSOCKET_INPUT_FLAG ) - { preadfds = &readfds; + + if ( flags & wxSOCKET_OUTPUT_FLAG ) + pwritefds = &writefds; + + // When using non-blocking connect() the client socket becomes connected + // (successfully or not) when it becomes writable but when using + // non-blocking accept() the server socket becomes connected when it + // becomes readable. + if ( flags & wxSOCKET_CONNECTION_FLAG ) + { + if ( m_server ) + preadfds = &readfds; + else + pwritefds = &writefds; + } + + if ( preadfds ) + { wxFD_ZERO(preadfds); wxFD_SET(m_fd, preadfds); } - // when using non-blocking connect() the socket becomes connected - // (successfully or not) when it becomes writable - if ( flags & (wxSOCKET_OUTPUT_FLAG | wxSOCKET_CONNECTION_FLAG) ) + if ( pwritefds ) { - pwritefds = &writefds; wxFD_ZERO(pwritefds); wxFD_SET(m_fd, pwritefds); }