Thread: [Question]What will happen if the server active close the connection?

[Question]What will happen if the server active close the connection?

From
"Wen Yi"
Date:
Hi team,
when I study the tcp connection, I found that if the server active close the connection, the server will send a fin package to the client and the client will reply a ack package.
As this:

Server ---->(FIN) Client
Server <----(ACK) Client

My question is, in so many articles, the following step is, the client will write some data(send some data) to the server and then cause the signal SIGNALPIPE.
But what will happen if the client died?(Example: was killed by the user)

Can someone provide some advice?
Thanks in advance!

Yours,
Wen Yi

Re: [Question]What will happen if the server active close the connection?

From
Laurenz Albe
Date:
On Mon, 2023-06-05 at 10:18 +0800, Wen Yi wrote:
> when I study the tcp connection, I found that if the server active close the connection,
> the server will send a fin package to the client and the client will reply a ack package.
> As this:
>
> Server ---->(FIN) Client
> Server <----(ACK) Client
>
> My question is, in so many articles, the following step is, the client will write some
> data(send some data) to the server and then cause the signal SIGNALPIPE.
> But what will happen if the client died?(Example: was killed by the user)

If the server has already closed the connection, nothing much will happen.
If the client never sends ACK to the FIN, the session will still time out.

You can fiddle with the tcp_keepalives_* parameters to influence that.

Yours,
Laurenz Albe