Thread: Winsock... What happens when the server dies?

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    55

    Winsock... What happens when the server dies?

    I have two applications:

    -A server, which is the one that calls listen().
    -A client, which is the one that calls connect().


    Ok, I've got them running on a LAN and they are constantly sending each other stuff. To make things short, just assume that the server is the one that sends all the time, and the client receives all the time.

    Well, when nothing strange happens, it works great. Also, when I unplug the Ethernet cable from the client, recv() returns SOCKET_ERROR, so I can do the necessary clean up and close my application correctly. However, when I unplug the Ethernet cable from the server I don't get a SOCKET_ERROR, recv() returns the size of the data I asked it to receive... Any ideas?

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    recv() may just be recv()ing data that has already arrived. Eventually, recv() should return an error, if there is no connection. (or send() will). Perhaps more detail/code?
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    recv will eventually return a WSAECONNABORTED or WSAECONNRESET

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. FTP and Ident Server :: Winsock
    By kuphryn in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-13-2004, 08:16 PM
  2. Winsock - Asynchrnonous Server problems
    By neandrake in forum Windows Programming
    Replies: 6
    Last Post: 06-24-2003, 06:19 PM
  3. Simple? winsock client - server problem
    By knutso in forum Windows Programming
    Replies: 2
    Last Post: 03-26-2003, 04:51 AM
  4. FTP Server :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 10-03-2002, 07:14 PM
  5. socket question
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-19-2002, 01:54 PM