🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Winsock help
i'm coding an asynchronous win32 winsock client application, and it seems that the WindProc function is not recognizing my WM_SOCKET messages, or something. so, when i want to read asynchronously, it doesn't. so far, i have,
#define WM_SOCKET WM_USER+1
WSAAsyncSelect(s, hWnd, WM_SOCKET, (FD_CLOSE | FD_CONNECT | FD_READ));
where WM_SOCKET is defined in my WindProc as:
case WM_SOCKET:
{
if(WSAGETSELECTERROR(lparam))
{
PostQuitMessage(0);
return 0;
}
switch(WSAGETSELECTEVENT(lparam))
{
case FD_CONNECT:
{}break;
case FD_READ:
{
....
char buffer[2];
recv(s, buffer, 2, 0);
//do some stuff
....
}break;
case FD_CLOSE:
{
...
}break;
}break;
what am i doing wrong? (ignore the poor syntax) my WM_SOCKET messages aren't being processed!
a2k
Edited by - a2k on 7/15/00 12:23:39 AM
There are a couple of things that you could be doing wrong, but I can''t see enough of your code to know for certain. One thing that IS wrong is that you''re passing lparam to WSAGETEVENTSELECT when it should be wparam instead. Also make sure that you do a WSAAsyncSelect on every accepted socket, as well as your listening socket. If you still have troubles post a little more of the code and I''ll help. You''re about to fall in love with async sockets though, they kick ass.
-BacksideSnap-
-BacksideSnap-
wparam? really? in an article a few weeks ago, lparam was passed to both. is this wrong? i''ll try it. also, my server is not asynchronous(for right now), so should the listening socket still be async? thanks so far, i''ll work on it...
a2k
a2k
figured it out. it was initialization. i had initialized my socket before my window, so the socket was pointing to null. (That''s one bad thing about putting everything in functions, it''s hard to see everything in order) and also, lparam is correct. lparam refers to the actual message whereas wparam refers to the socket.
a2k
a2k
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement