UDP sendto()何时阻止? [英] When does a UDP sendto() block?

查看:83
本文介绍了UDP sendto()何时阻止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在UDP套接字上使用默认(阻止)行为时,在哪种情况下,对sendto()的调用会阻止?我对Linux的行为本质上很感兴趣.

While using the default (blocking) behavior on an UDP socket, in which case will a call to sendto() block? I'm interested essentially in the Linux behavior.

对于TCP,我知道如果发送窗口已满,则拥塞控制会使send()调用阻塞,但是UDP呢?它有时会阻塞还是只是让数据包在较低层被丢弃?

For TCP I understand that congestion control makes the send() call blocking if the sending window is full, but what about UDP? Does it even block sometimes or just let packets getting discarded at lower layers?

推荐答案

如果您填满套接字缓冲区,则可能会发生这种情况,但这是高度依赖操作系统的.由于UDP不提供任何保证,因此您的操作系统可以在套接字缓冲区已满时决定采取任何措施:阻止还是丢弃.您可以尝试增加SO_SNDBUF以获得暂时的救济.

This can happen if you filled up your socket buffer, but it is highly operating system dependent. Since UDP does not provide any guarantee your operating system can decide to do whatever it wants when your socket buffer is full: block or drop. You can try to increase SO_SNDBUF for temporary relief.

这甚至可能取决于系统的微调,例如,它还可能取决于网络接口驱动程序中TX环的大小.在 iperf邮件列表,但您确实想与操作系统的开发人员进行讨论.请特别注意O_NONBLOCK和EAGAIN/EWOULDBLOCK.

This can even depend on the fine tuning of your system, for instance it can also depend on the size of the TX ring in the driver of your network interface. There are a few discussions about this in the iperf mailing list, but you really want to discuss this with the developers of your operating system. Pay special attention to O_NONBLOCK and EAGAIN / EWOULDBLOCK.

这篇关于UDP sendto()何时阻止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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