Archived

This topic is now archived and is closed to further replies.

Winsock help

This topic is 6359 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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-

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites