admin 管理员组

文章数量: 887017

Windows下写网络程序时遇到很多TIME_WAIT、CLOSE_WAIT的网络连接,可以通过调整

注册表中的TCP参数来处理:


<span style="font-size:14px;">C:\Users\user1>netstat -ano | findstr 110:80
  TCP    192.168.1.110:80       192.168.1.7:33083      TIME_WAIT       0
  TCP    192.168.1.110:80       192.168.1.7:37372      TIME_WAIT       0
  TCP    192.168.1.110:80       192.168.1.7:46898      TIME_WAIT       0
  TCP    192.168.1.110:80       192.168.1.7:50968      ESTABLISHED     175540
  TCP    192.168.1.110:80       192.168.1.7:51137      TIME_WAIT       0
  TCP    192.168.1.110:80       192.168.1.7:53271      TIME_WAIT       0
  TCP    192.168.1.110:80       192.168.1.7:57955      TIME_WAIT       0
  TCP    192.168.1.110:80       192.168.1.8:42506      TIME_WAIT       0
  TCP    192.168.1.110:80       192.168.1.8:42940      TIME_WAIT       0</span>

打开运行输入“regedit”打开注册表,进入路径“HKEY_LOCAL_MACHINE\SYSTEM\

CurrentControlSet\Services\Tcpip\Parameters”,增加或者调整下面几个参数:

KeepAliveTime            30000
KeepAliveInterval        2000
TcpTimedWaitDelay        30000


本文标签: 网络 Windows CLOSEWAIT TIMEWAIT