TCP 写入连接超时(netstat 显示 ESTABLISHED)
我做了一个实验:
服务器监听8804端口,接受客户端的连接,然后不断地向客户端发送数据。我关闭网络。
- 当我运行 netstat -anotp | grep 8804 ,显示服务器和客户端的连接均已“建立”,但没有数据传输。
- 过了一会儿,服务器抛出一个错误:“连接超时”
- netstat -anotp | grep 8804 并发现客户端仍然是“ESTABLISHED”
所以:
1. 为什么在系统调用“write”上被阻塞的服务器会抛出“连接超时”错误。为什么不是客户?
2. 如何让客户端发现连接实际上已关闭。
3. 网络不通时,为什么服务器和客户端的状态都是“ESTABLISHED”?
感谢您的回答!
I made an experiment:
A server listens on port 8804 accepts a connection of a client and then send data to the client endless. I shutdown the network.
- When I run netstat -anotp | grep 8804 ,it shows that the connection is "ESTABLISHED" on both server and client , but there is no data transmission.
- After a while , the server throw an error : "Connection time out"
- netstat -anotp | grep 8804 and found that the client is still "ESTABLISHED"
So:
1. Why does the server which is blocked on the system call "write" throw the "Connection timeout" error. Why not the client ?
2. How to let the client find the connection is shutdown actually.
3. Why are the server and client's statuses both "ESTABLISHED" when the network does not work ?
Thanks for your answer !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
s
):编辑:
由于您使用的是 C,因此链接到 Linux TCP Keepalives Howto
注释
s
):EDIT:
Since you're using C, a link to the Linux TCP Keepalives Howto
NOTES