- 论坛徽章:
- 17
|
回复 8# Aquester
close的行为典型的情况下受linger选项的影响,针对linger的设置来讲,当其l_onoff非0,且l_linger为0,那么当套接口关闭时TCP将丢弃保留的套接口发送缓冲区的任何数据并发送一个 RST给对方。另一方面TCP的规范RFC 2525第2.17节规定了“如果缓存区有未读数据那么关闭socket将会发送RST给对放方“,linux实现符合些标准了,所以楼主情况是合理的。
RFC中的原话如下:
When an application closes a connection in such a way that it can
no longer read any received data, the TCP SHOULD, per section
4.2.2.13 of RFC 1122, send a RST if there is any unread received
data, or if any new data is received. A TCP that fails to do so
exhibits "Failure to RST on close with data pending".
linger发送RST的行为在man文档中有比较隐晦的说明:
If SO_LINGER is disabled and a close is issued, the sys-
tem will process the close in a manner that allows the process to con-
tinue as quickly as possible |
|