是什么原因导致水管坏了错误? [英] What causes the Broken Pipe Error?

查看:185
本文介绍了是什么原因导致水管坏了错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,当在对端关闭套接字破裂的管道引发错误。

I know that broken pipe error is thrown when the socket on the peer side is closed.

不过,在我的测试中,我注意到,立即发送电话这边的时候对端是封闭的并不总是导致水管坏的错误。

But, in my test I have noted that an immediate 'send' call on this side when the peer side is closed doesn't always lead to a broken pipe error.

例如:

收盘对端插座(我已经通过调用杀死同行接近,也异常的收盘尝试干净关闭)后,如果我尝试发送40字节的话,我没有得到一个破裂的管道,但是如果我尝试发送40000字节,然后立即给水管坏的错误。

After closing the socket on peer side (I have tried clean closing by calling close and also abnormal closing by killing the peer), if I try to send 40 bytes, then I don't get a broken pipe, but, if I try to send 40000 bytes then it immediately gives broken pipe error.

是什么导致断管和可它的行为是predicted?

What exactly causes broken pipe and can it's behavior be predicted?

推荐答案

可能需要一段时间的网络接近观察 - 总的标称值为约2分钟(是的,分钟!)数据包发往前一收盘后为端口都假定为死亡。错误条件在一些点被检测到。用小的写入,则是系统的MTU里面,所以该消息被排队以供发送。有了一个大的写的,你比MTU大,系统斑点问题更快。如果忽略SIGPIPE信号,则函数将在一个破碎的管道返回EPIPE错误 - 在检测到连接的破碎岬当一些点

It can take time for the network close to be observed - the total time is nominally about 2 minutes (yes, minutes!) after a close before the packets destined for the port are all assumed to be dead. The error condition is detected at some point. With a small write, you are inside the MTU of the system, so the message is queued for sending. With a big write, you are bigger than the MTU and the system spots the problem quicker. If you ignore the SIGPIPE signal, then the functions will return EPIPE error on a broken pipe - at some point when the broken-ness of the connection is detected.

这篇关于是什么原因导致水管坏了错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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