My server program (socket stream) is running and it accepts the clients. Due to some abnormal condition, server is getting terminated. The other side clients are waiting for server reply. How to I reconnect the running clients to new server? any functions in sockets?
Automatically Reconnect to a Server on a PCOpen File Explorer and select This PC. Select the Computer tab, then select Map Network Drive. Enter the IP address of the server or share name to give the path of the shared drive, then check the box next to Reconnect at sign-in. Wait for the drive to be mapped.
The network configuration has changed (ie. The internal server IP has changed, the dynamic internet IP has changed, port 8082 is blocked, etc.). There is a firewall blocking the connection (ie. Windows Firewall on either the server or the client, 3rd party firewall software, the firewall on the router).
A socket that had been connect()
ed once cannot be reused with another call to connect()
.
The steps to connect to a TCP server and read/write some data are as follows (pseudo code):
sd = socket(...) // create socket descriptor (allocate socket resource)
connect(sd, server-address, ...) // connect to server
read/write(sd, data) // read from server
close(sd) // close /socket descriptor (free socket resource)
In case the server goes down after connect
all the client could and shall do is
close(sd) // close socket descriptor (free socket resource)
and then start over beginning with:
sd = socket(...) // create socket descriptor (allocate socket resource)
...
Starting over beginning with:
connect(sd, server-address, ...) // connect to server
...
would probably lead to undefined behaviour, but at least to an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With