Can writing to a UDP socket ever block?

大兔子大兔子 提交于 2019-12-03 23:57:10

Yes, oddly, a UDP socket can block.

The conditions under which this can happen are basically, some buffers somewhere fill up, your operating system decides it's time for something to block. These are arguably kernel bugs, but I've seen them here and there. You can definitely get EWOULDBLOCK sometimes under obscure, impossible-to-reproduce conditions.

Why would you want to do this in Twisted instead of using Twisted's built-in UDP support though?

It could fail if your network interface goes down, for example:

[ENETDOWN] The local network interface used to reach the destination is down.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!