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

Started by Wen Yialmost 3 years ago2 messagesgeneral
Jump to latest
#1Wen Yi
896634148@qq.com

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

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Wen Yi (#1)
Re: [Question]What will happen if the server active close the connection?

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