|
-
November 7th, 2012, 09:51 AM
#6
Re: CAsyncSocket close problem
 Originally Posted by bkelly
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.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|