WSAAsyncSelect (socketIdentifier, hwnd, MY_MESSAGE_NOTIFICATION, FD_READ | FD_CONNECT | FD_CLOSE | FD_ACCEPT); //Making the socket Asynchronous while(GetMessage(&Msg, NULL, 0, 0) > 0) //Waiting for windows messages { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case MY_MESSAGE_NOTIFICATION: //Window message generated by asynchronous socket. { switch (lParam) //If so, which one is it? { case FD_ACCEPT: //Connection request was made break; case FD_CONNECT: //Connection was made successfully break; case FD_READ: receiveAtSocket(); break; case FD_CLOSE: //Lost the connection break; } } break; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)