All messages are queued.
You have to catch the WM_WSAASYNC message:
ON_MESSAGE( WM_WSAASYNC, &MyClass::OnSocketNotification )
Handle it like this:
Code:
LRESULT MyClass::OnSocketNotification(WPARAM wParam, LPARAM lParam)
{
WORD wEvent = WSAGETSELECTEVENT(lParam);
WORD wError = WSAGETSELECTERROR(lParam);
SOCKET hSock = (SOCKET)wParam; // for which socket is this notification
if( wError )
{
// error handling
}
switch( wEvent ) // which event occurred for hsock
{
case FD_CONNECT:
// hsock is connected
break;
case FD_CLOSE:
// hsock is closed
break;
case FD_READ:
// hsock can start to recv
break;
case FD_WRITE:
// hsock can start to send
default:
break;
}
return( 0L );
}