Knowing when a client disconnects [Archive] - C Board

PDA

View Full Version : Knowing when a client disconnects


dp_goose
07-24-2003, 03:03 AM
I am in the process of creating a server using C++ and TCPIP. I have created a socket, bound it to a port, set it to list and then accept dynamically created multiple connections (created as new sockets).

How can I find out / be notified that a connection has been disconnected at the client end so that I can clean up the sockets?

Goose

Hammer
07-24-2003, 06:53 AM
The client has gone when a read on the socket returns 0.

I suggest beej's guide, there's a link to it in the links thread on this forum.

dp_goose
07-24-2003, 08:22 AM
If I had seen those links yesterday I wouldn't have wasted £25 on a TCP/IP Programming book that doesn't have the information anyway.

Thanks for the info