Advertisement

Winsock Asynchronous sockets and c++ MFC help?

Started by August 15, 2004 07:31 AM
2 comments, last by adiash 20 years, 6 months ago
Hi, im using winsock 2, asynchronous sockets in c++ MFC. My problem is that I need to put a case WM_ONSOCKET (WM_USER+1) inside the message handler. But MFC hides the messenger handler, so what would I do? Thanks
Hi,
If I understand correctly your problem is that you are lacking a function to handle the message you defined.
Here is what you can do :
Use the ON_MESSAGE macro in your message map like so :
BEGIN_MESSAGE_MAP(CYourDialog, CDialog)	//{{AFX_MSG_MAP(CYourDialog)        ON_MESSAGE (WM_ONSOCKET , OnSocketOrWhateverYouWannaCallIt)	ON_WM_PAINT() //just a sample 	ON_WM_QUERYDRAGICON() //just a sample	//}}AFX_MSG_MAPEND_MESSAGE_MAP()


in the header use the following prototype for your handler:
afx_msg LRESULT OnSocketOrWhateverYouWannaCallIt(WPARAM wParam, LPARAM lParam);


Last thing you need to do is naturally implelement the function in the .cpp file.

Hope this help and good luck! [smile]
_________ Evious Ltd.
Advertisement
thanks, i think i got it working, but because this is my first time using winsock in c++, i am wondering if there is anyway that i could test that the:

LRESULT CHostDlg::OnWinsock(WPARAM wParam, LPARAM lParam)

is actually working, that is the wParam and lParam are receiving variables.

thanks
Of course there is a way! [smile]
use the WSAGETSELECTEVENT macro on LPARAM to see the type of notification you received.
Actually, I think it would be best if you just read this , it really covers what you are looking for.
_________ Evious Ltd.

This topic is closed to new replies.

Advertisement