Here is what I want the CLIENT to do.
Check and see if the server is up, if not, keep trying until it is.
If the server is up, then connect to it.
If the server goes offline or quits. Go back to step 1.
Here is my code so far:
Code:
while(1) {
nret = connect(serverSocket, (LPSOCKADDR)&serverInfo, 16);
if(nret == SOCKET_ERROR) {
connected = false;
}
else {
recvResponse(serverSocket, true); // recieves server's welcome message
connected = true;
}
while(connected) {
// do stuff
if(server_disconnects)
connected = false;
}
}
This works fine for one connection, but If the server quits, and then restarts, the client will NOT connect.
Any suggestions?