#include "wx/gsocket.h"
#include "wx/apptrait.h"
+#include "wx/link.h"
+
+wxFORCE_LINK_THIS_MODULE(gsockmsw)
extern "C" WXDLLIMPEXP_BASE HINSTANCE wxGetInstance();
#define INSTANCE wxGetInstance()
/* Remove the socket from the list */
EnterCriticalSection(&critical);
if ( socket->IsOk() )
- socketList[(socket->m_msgnumber - WM_USER)] = NULL;
+ {
+ const int msgnum = socket->m_msgnumber;
+
+ // we need to remove any pending messages for this socket to avoid having
+ // them sent to a new socket which could reuse the same message number as
+ // soon as we destroy this one
+ MSG msg;
+ while ( ::PeekMessage(&msg, hWin, msgnum, msgnum, PM_REMOVE) )
+ ;
+
+ socketList[msgnum - WM_USER] = NULL;
+ }
+
LeaveCriticalSection(&critical);
}
static GSocketMSWManager s_manager;
wxAppTraits::SetDefaultSocketManager(&s_manager);
}
-} gsm_managerSetter;
+} gs_managerSetter;
#endif // wxUSE_SOCKETS