Hey, I've been writing a little chat server and I needed to do asynchronous sockets for it. So I set up the socket, binded it to the port and listened, then I passed the WSAAsyncSelect() function. Now, here is what my message-handler function looks like:
Now, I run the program and I CAN connect to it, so I know that it's working, however you see where I called the MessageBox function above, those never show up. I don't have a clue as to why it wouldn't execute that function or block it from showing up at all. Hmm... Any help is appreciated.Code:LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_SOCKETMESSAGE: //my defined message(WM_USER+1) if(WSAGETSELECTERROR(lParam)) { WSACleanup(); return 0; } switch(WSAGETSELECTEVENT(lParam)) { case FD_CONNECT: clientSocket=accept(listeningSocket,NULL,NULL); if(clientSocket==INVALID_SOCKET) WSACleanup(); else MessageBox(hwnd,"Connection established!","Incoming Connection",MB_OK); break; case FD_CLOSE: closesocket(clientSocket); break; case FD_READ: memset(buffer,0,500); recv(clientSocket,buffer,500,0); MessageBox(hwnd,buffer,"New Data Received",0); break; } return 0;



LinkBack URL
About LinkBacks



.