void Socket::Disconnect(bool bAbort)
{
if(!m_bConnected)
return;
m_bConnected = false;
if(bAbort)
sLog.outDetail("<Socket %u> Abortively disconnected.", GetSocket());
else
sLog.outDetail("<Socket %u> Gracefully disconnected.", GetSocket());
OnDisconnect();
sLog.outString("After OnDisconnect() function");
sSocketManager.RemoveSocket(this);
if(m_SocketHandle != INVALID_SOCKET)
{
//////////////////////////////////////////////////////////////////////////
//shutdown
//To ensure that all data an application sends is received by the peer,
//a well-written application should notify the receiver that no more data is to be sent.
//SD_BOTH disables both sends and receives
::shutdown(m_SocketHandle, SD_BOTH);
//////////////////////////////////////////////////////////////////////////
//closesocket
//The closesocket function closes a socket
//Calling closesocket releases the socket descriptor and any further calls using the socket fail with WSAENOTSOCK.
//If there are no other references to this socket, all resources associated with the descriptor are released.
//This includes discarding any queued data.
::closesocket(m_SocketHandle);
}
m_SocketHandle = INVALID_SOCKET;
sSocketManager.EraseSocket(this);
// delete this;
sLog.outString("Disconnect function ended");
}