November 6th, 2012, 08:41 PM
CAsyncSocket close problem
Environment: windows XP and Win 7, Visual Studio 2008, MFC, C++, CAsyncSocket
Setup: I wrote a test program that drives the server side and the client side of a TCP/IP connection using CAsyncSocket. It uses a C_Server class to listen for the client and accept the connection. That class creates an instance of the C_Server_Send object to send data to the client. It is working but is missing the proper closing function. I am working on fixing that. Now when the client closes the socket the C_Server_Send OnClose() is called. But I don’t know what to do here. The CAsyncSocket::Close does not appear to cause the object to delete itself. C_Server does not know that OnClose() has been called so the object that created this cannot delete it.
When the client closes the connection, what is the proper method to delete object CAsyncSocket?
In all the On*() overridden methods, should I load them up with error checking such as WSAGetLastError()?
Note: If interested, I wrote up an article on this and posted it on codeproject.com here:
I have since realized that while it ends with error code zero, it still does not have proper closing code. That work is in progress. I discovered this as I started implementing my code in a real world application.
Last edited by bkelly; November 6th, 2012 at 08:42 PM.
Click Here to Expand Forum to Full Width