Thread: Socket State (connected or not)

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    4

    Socket State (connected or not)

    how can i check that current state of a socket? if its connected or not
    i have multiple clients on a server and i want to check if client X is still connected or not

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    The easiest way is to send across some data every so often and see if the client responds.

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    3
    If you send to the socket and it returns error 10057 WSAENOTCONN then you know that the socket is not connected.

    More details on error handling can be found here;

    Winsock error handling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Grammar to FSA to C code (Newbie)
    By aybe in forum C Programming
    Replies: 4
    Last Post: 02-29-2008, 02:10 PM
  2. input/switch statement issues
    By peanut in forum C Programming
    Replies: 5
    Last Post: 10-27-2006, 02:58 PM
  3. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 10:56 AM
  4. Checking Socket State
    By XSquared in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-09-2004, 10:16 PM
  5. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM