Thread: Knowing when a client disconnects

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    2

    Question Knowing when a client disconnects

    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

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    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.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    2
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Socket Programming Problem!!!!
    By bobthebullet990 in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-21-2008, 07:36 PM
  2. WSAAsyncSelect Socket Model. She's Not Hot.
    By Tonto in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-24-2007, 08:34 AM
  3. Client works on a LAN but don't send all the data
    By Niara in forum Networking/Device Communication
    Replies: 9
    Last Post: 01-04-2007, 04:44 PM
  4. Replies: 1
    Last Post: 09-18-2005, 09:06 PM
  5. Unicode vurses Non Unicode client server application with winsock2 query?
    By dp_76 in forum Networking/Device Communication
    Replies: 0
    Last Post: 05-16-2005, 07:26 AM