TIME_WAIT 与 boost asio [英] TIME_WAIT with boost asio

查看:50
本文介绍了TIME_WAIT 与 boost asio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了官方的 tcp 回显服务器示例

解决方案

  • CLOSE_WAIT 是编程错误.本地应用程序已收到传入关闭但尚未关闭此端.

  • TIME_WAIT 在双方完全断开连接之后出现,并且只持续几分钟.避免它的方法是成为接收第一个关闭的结束.通常,您希望在服务器上避免它,因此您首先关闭客户端.

I tried the official tcp echo server example server and client. With netstat -ano | findstr TIME_WAIT I can see the client causes a TIME_WAIT every time, while the server disconnects cleanly.

Is there anyway to prevent the TIME_WAIT or CLOSE_WAIT, that disconnect cleanly for both sides?

Here's the captured packets, seems the last ACK is sent correctly, but still there is TIME_WAIT on client side.

解决方案

  • CLOSE_WAIT is a programming error. The local application has received an incoming close but hasn't closed this end.

  • TIME_WAIT comes after a clean disconnect by both parties, and it only lasts a few minutes. The way to avoid it is to be the end that receives the first close. Typically you want to avoid it at the server, so you have the client close first.

这篇关于TIME_WAIT 与 boost asio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆