Quote Originally Posted by bkelly View Post
When the client closes the connection, and if C_Server_Send has a read posted, method OnClose() of C_Server_Send is called. C_Server_Send can terminate communications and perform the Close() method. However, that does not delete the object.
Maybe you could perform something like
Code:
void C_Server_Send::OnClose(int nErrorCode) 
{
	//	socket is to close due to other side demand
	if(m_hSocket != INVALID_SOCKET)
		ShutDown(both);
	CAsyncSocket::Close();

	CAsyncSocket::OnClose(nErrorCode);
	delete this;
}
Note that I never used such a code myself (just because I create a new thread for every new connection, thus do NOT new the socket object and instead create in in stack in the corresponding thread) and am not sure it is not dirty.