I understand, using sockets, how I can tell that the server has been disconnected..... is there a way the client can retry connecting for a given time automatically before giving up??
I understand, using sockets, how I can tell that the server has been disconnected..... is there a way the client can retry connecting for a given time automatically before giving up??
If the server disconnects CORRECTLY, then your client will return 0 from the next call to recv() or send(). That's how you know the connection has terminated gracefully. If the server disconnects improperly there is no way to know that anything has happened. You just won't receive packets from the server any more, and any attempt to transmit packets to the server just goes into the void.
In other words, if a network connection goes down because, say, a rat is chewing on a cable somewhere, you won't get any special message like E_RAT_CHEWING_ON_CABLE.
TCP is a robust protocol. You should never "give up." The operating system (in particular, the TCP/IP networking stack) will make that decision for you by eventually returning 0 from recv() or send().
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}