- 論壇徽章:
- 17
|
回復 8# Aquester
close的行為典型的情況下受linger選項的影響,針對linger的設置來講,當其l_onoff非0,且l_linger為0,那么當套接口關閉時TCP將丟棄保留的套接口發(fā)送緩沖區(qū)的任何數(shù)據(jù)并發(fā)送一個 RST給對方。另一方面TCP的規(guī)范RFC 2525第2.17節(jié)規(guī)定了“如果緩存區(qū)有未讀數(shù)據(jù)那么關閉socket將會發(fā)送RST給對放方“,linux實現(xiàn)符合些標準了,所以樓主情況是合理的。
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發(fā)送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 |
|