5.15 Crashing and Rebooting of Server
Host
In this scenario, we will establish a connection
between the client and server and then assume the server host
crashes and reboots. In the previous section, the server host was
still down when we sent it data. Here, we will let the server host
reboot before sending it data. The easiest way to simulate this is
to establish the connection, disconnect the server from the
network, shut down the server host and then reboot it, and then
reconnect the server host to the network. We do not want the client
to see the server host shut down (which we will cover in Section
5.16).
As stated in the previous section, if the client
is not actively sending data to the server when the server host
crashes, the client is not aware that the server host has crashed.
(This assumes we are not using the SO_KEEPALIVE socket
option.) The following steps take place:
-
We start the
server and then the client. We type a line to verify that the
connection is established.
-
The
server host crashes and reboots.
-
We
type a line of input to the client, which is sent as a TCP data
segment to the server host.
-
When
the server host reboots after crashing, its TCP loses all
information about connections that existed before the crash.
Therefore, the server TCP responds to the received data segment
from the client with an RST.
-
Our
client is blocked in the call to readline when the RST is
received, causing readline to return the error
ECONNRESET.
If it is important for our client to detect the
crashing of the server host, even if the client is not actively
sending data, then some other technique (such as the
SO_KEEPALIVE socket option or some client/server heartbeat
function) is required.
|