Do wait for connection in the server socket.

The code returned immediately from wxSocketBase::DoWait() if it wasn't
connected but it only made sense for the client sockets, not server ones which
could be calling this function precisely in order to wait until a connection
is made.

Also added a test for this bug in the sockets/server sample.

Closes #11107.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61726 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-08-21 15:25:09 +00:00
parent d94e9b623a
commit 1b4b608091
2 changed files with 21 additions and 3 deletions

View File

@@ -1355,8 +1355,10 @@ wxSocketBase::DoWait(long timeout, wxSocketEventFlags flags)
{
wxCHECK_MSG( m_impl, -1, "can't wait on invalid socket" );
// we're never going to become ready if we're not connected (any more)
if ( !m_connected && !m_establishing )
// we're never going to become ready in a client if we're not connected any
// more (OTOH a server can call this to precisely wait for a connection so
// do wait for it in this case)
if ( !m_impl->IsServer() && !m_connected && !m_establishing )
return -1;
// This can be set to true from Interrupt() to exit this function a.s.a.p.