in reply to Win32 sockets and disconnects

Why are you closing your listening socket, then recreating it? Seems like asking for trouble to me. Are you sure that its getting recreated properly? I tried similar code to yours, and on the recreation of the listening socket, it errrored out as the Address already being in use. Is it really necessary to recreate that socket? Also, are you intending on handling multiple clients? If so you'd better change this up a bit. You can see an example of a polling loop that works here

cephas

Replies are listed 'Best First'.
Re: Re: Win32 sockets and disconnects
by HaB (Sexton) on Dec 13, 2000 at 18:30 UTC
    The reason for the recreation of the socket is that the previous version, which I am being contracted to replace completely, attempted to keep the same socket open forever, which over the internet, is wishful thinking. It could *never* tell if it was disconnected or not, and would therefore never accept a re-connection attempt from a dropped client. In the socket creation routine, I am setting SO_REUSEADDR, so reusing the same address is no problem. Also, the socket creation routine would return error if it couldn't create a new socket, so I'm pretty sure that's all correct.

    As far as multiple clients goes, oddly enough, it will not be handling multiple clients. These are set up on a 1 to 1 ratio, clients to servers. I had actually started out with a polling version, because I also was under the impression that it may have to handle multiple clients (even if not now, but perhaps one day), and I was told that no...it would never happen. *shrug*

    Thanks a lot for the reply.


    -HaB


    hword.