How would I make a client program that tries to connect to a server, and if it failed, tries to connect again, until it successfuly connects?
How would I make a client program that tries to connect to a server, and if it failed, tries to connect again, until it successfuly connects?
Code:int forAwhile = 5; /* seconds */ while ( !connected() ) { tryAndConnect(); sleep(forAwhile); }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.