Home > Software engineering >  CSOKET server which is how to identify the close client
CSOKET server which is how to identify the close client

Time:04-02

Through OnAccept access to all the client socket connection and save to the queue,
Now the problem is, when a client disconnects, the service side is how to identify the queue in which the socket, and remove?
Void CServer: : OnAccept (int nErrorCode)
{
CSocket * pSocket=new CSocket ();
If (Accept pSocket) (*)
{
M_Clientlist. AddTail (pSocket);
}
The else
{
The delete pSocket;
}
CSocket: : OnAccept (nErrorCode);
}

Void CServer: : OnClose (int nErrorCode)
{
CSocket: : OnClose (nErrorCode);
}

CodePudding user response:

getpeername

  • Related