大网数据广告活动
服务器运维问答

What happens when a Server sends a data packet to the Client when the later (Client) is on TCP FIN-WAIT-1 state?

· 52CE 我爱测

According to TCP/IP Guide , when a TCP session is closed by the Client, it will send a packet with FIN set to the Server and transition to FIN-WAIT-1 , however it says: In this state the client can still receive data from the ser…

问题原文

原帖链接 · ligregni · CC BY-SA 3.0

According to TCP/IP Guide, when a TCP session is closed by the Client, it will send a packet with FIN set to the Server and transition to FIN-WAIT-1, however it says:

In this state the client can still receive data from the server but will no longer accept data from its local application to be sent to the server.

So, my question is, what happens if the Server sends data back to the Client? since the application may probably be closed already or not in a state where it can read from the socket anymore, where is the data going to go? Also, is the client going to send ACK back for that data? what happens with the connection then? (RST maybe?)

Note: I don't care about such data, I just want to know if there is potentially a memory leak given that no process read from the TCP buffer, or if the network stack itself will take care of this.

Thank you.

已采纳解答

原帖链接 · womble · CC BY-SA 3.0

since the application may probably be closed already or not in a state where it can read from the socket anymore, where is the data going to go?

It's implementation dependent. If the socket's closed on the application end, the TCP stack can just drop that incoming data on the floor. Alternately, you could have an implementation which didn't return from the close() call (or equivalent) until the server's FIN is received, allowing another thread to continue to read() from the socket (although a write() would receive an error). If the read() didn't complete before the server's FIN arrived, EOF could be signalled. (Replace "thread" with "callback" in an async model).

Best way to answer your question: test it on your preferred implementation(s).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。