Winsock... What happens when the server dies?

This is a discussion on Winsock... What happens when the server dies? within the Windows Programming forums, part of the Platform Specific Boards category; I have two applications: -A server, which is the one that calls listen(). -A client, which is the one that ...

  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,189
    recv will eventually return a WSAECONNABORTED or WSAECONNRESET
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

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, 07: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, 03: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21