7、FIN-WAIT-2
处于 FIN-WAIT-1状态的连接收到 ACK 确认包以后进入FIN-WAIT-2状态,这个时候主动关闭方的 FIN 包已经被对方确认,等待被动关闭方发送 FIN 包。
客户端超时关闭,服务端在正在处理,没法关闭,客户端处于FIN-WAIT-2
客户端:
node2:/root#netstat -an | grep 8080
tcp 0 0 192.168.137.3:57075 192.168.137.2:8080 FIN_WAIT2
node2:/root/test#cat t19.py
import socket
import time
import struct
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
# SEND_BUF_SIZE = 2
s.connect(("192.168.137.2",8080))
s.settimeout(10)
s.send('112233')
s.recv(999)
node2:/root/test#time python t19.py
Traceback (most recent call last):
File "t19.py", line 9, in <module>
s.recv(999)
socket.timeout: timed out
real 0m10.066s
user 0m0.027s
sys 0m0.021s
服务端:
node1:/root#netstat -na | grep 8080
tcp 0 0 192.168.137.2:8080 0.0.0.0:* LISTEN
tcp 1 0 192.168.137.2:8080 192.168.137.3:57075 CLOSE_WAIT
node1:/root/test#cat t2.py
7、FIN-WAIT-2
最新推荐文章于 2022-08-06 23:18:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)