the code:
Code: Select all
//src/msw/sockmsw.cpp
/* Windows proc for asynchronous event handling */
LRESULT CALLBACK wxSocket_Internal_WinProc(HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
if ( uMsg < WM_USER || uMsg > (WM_USER + MAXSOCKETS - 1))
return DefWindowProc(hWnd, uMsg, wParam, lParam);
wxSocketImplMSW *socket;
wxSocketNotify event = (wxSocketNotify)-1;
{
wxCRIT_SECT_LOCKER(lock, gs_critical);
socket = socketList[(uMsg - WM_USER)];
if ( !socket )
return 0;
// the socket may be already closed but we could still receive
// notifications for it sent (asynchronously) before it got closed
if ( socket->m_fd == INVALID_SOCKET )
return 0;
wxASSERT_MSG( socket->m_fd == (SOCKET)wParam,
"mismatch between message and socket?" ); //<-------------------Error here----------------
switch ( WSAGETSELECTEVENT(lParam) )
{
case FD_READ:
// We may get a FD_READ notification even when there is no data
// to read on the socket, in particular this happens on socket
// creation when we seem to always get FD_CONNECT, FD_WRITE and
// FD_READ notifications all at once (but it doesn't happen
// only then). Ignore such dummy notifications.
{
fd_set fds;
timeval tv = { 0, 0 };
wxFD_ZERO(&fds);
wxFD_SET(socket->m_fd, &fds);
if ( select(socket->m_fd + 1, &fds, NULL, NULL, &tv) != 1 )
return 0;
}
event = wxSOCKET_INPUT;
break;
case FD_WRITE:
event = wxSOCKET_OUTPUT;
break;
case FD_ACCEPT:
event = wxSOCKET_CONNECTION;
break;
case FD_CONNECT:
event = WSAGETSELECTERROR(lParam) ? wxSOCKET_LOST
: wxSOCKET_CONNECTION;
break;
case FD_CLOSE:
event = wxSOCKET_LOST;
break;
default:
wxFAIL_MSG( "unexpected socket notification" );
return 0;
}
} // unlock gs_critical
socket->NotifyOnStateChange(event);
return 0;
}