tlsoftware
asked on
MFC: CSocket
Basically I am coming from using the native windows api and the native winsock api so please bear with me.
This is my first mfc application.
I want to have an mfc application use the CAsyncSocket class to listen for connections. And when various network events happen such as FD_ACCEPT, it to send a message to the window so that I can accept the connection. But how can I get it to do this? There doesn't seem to be any functionallity in the class which lets me tell it to notify this window. I have tried using the WSAAsyncSelect to specify the m_hWnd member of the window class to notify me of FD_ACCEPT events, but it doesn't work. It could be a problem with the way I try and receive the message. I added the ON_MESSAGE(FD_ACCEPT,OnAcc ept) statement to the message map for that window. Is that right? Can CAsyncSocket do this for me? Any help would be greatly appreciated.
This is my first mfc application.
I want to have an mfc application use the CAsyncSocket class to listen for connections. And when various network events happen such as FD_ACCEPT, it to send a message to the window so that I can accept the connection. But how can I get it to do this? There doesn't seem to be any functionallity in the class which lets me tell it to notify this window. I have tried using the WSAAsyncSelect to specify the m_hWnd member of the window class to notify me of FD_ACCEPT events, but it doesn't work. It could be a problem with the way I try and receive the message. I added the ON_MESSAGE(FD_ACCEPT,OnAcc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are wondering how to get the notification messages, you do not get them. The CAsyncSocket class creates its own (hidden) window to catch the async notification messages, it then calls the OnXxxx() functions defined in the class.
The ideal way to use this class is to derive a new class from it, and override the OnXxxxx() functions (CAsyncSocket::OnAccept(), CAsyncSocket::OnSend(), etc).
When a connection is ready to be accepted, the Winsock API sends the message to the CAsyncSocket object, which in turn calls the OnAccept() function. Get it?
Is that what you are looking for?
-=- James.
The ideal way to use this class is to derive a new class from it, and override the OnXxxxx() functions (CAsyncSocket::OnAccept(),
When a connection is ready to be accepted, the Winsock API sends the message to the CAsyncSocket object, which in turn calls the OnAccept() function. Get it?
Is that what you are looking for?
-=- James.
ASKER