2uzhan.com
Advertisement
Now Place:2uzhan.com » Detecting a closed connection.

Detecting a closed connection.

Network Programming @ January 20, 2006   Views:0

On my server I need to find out if a connection is closed. For example if I am using Telnet and I close telnet, my server can't tell that the connection is closed by using select. Is there anyway for me to detect when a client abords the connection?

Help me please.

--------------Solutions-------------

hi,

U can override the CASyncSocket::OnClose method this method is called by the framework(MFC) to notify this socket that the connected socket is closed by its process. u could possibly put some messagebox in the method to notify the user.

I am using the Raw WinSock API

You can use WSAAsyncSelect to receive a message notifying you of certain events, FD_CLOSE (signalling that the connection has been closed) is one of them.

Nevermind I already figured out how to do it with select and recv. The combination of the two make a perfect receptor part of a server.

recv() returns 0 when connection is closed from other end either by FINs or RST.

Tags:
© 2018 2uzhan.com Contact