在python中断开UDP套接字? [英] Disconnect UDP socket in python?
本文介绍了在python中断开UDP套接字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在 python 中断开"一个 UDP 套接字(而不是关闭它!).
I need to 'disconnect' a UDP socket in python(and not close it!).
是否可以做等价的:
int disconnect_udp_sock(int fd)
{
struct sockaddr_in sin;
memset((char *)&sin, 0, sizeof(sin));
sin.sin_family = AF_UNSPEC;
return (connect(fd, (struct sockaddr *)&sin, sizeof(sin)));
}
取自 此处 在 python 中没有接口函数?
taken from here in python without interfacing the function?
推荐答案
查看 Python 2.7 源代码中的 socketmodule.c,似乎不可能.您确实需要定义和调用上面的 C 函数.
Looking at socketmodule.c in the Python 2.7 sources, it doesn't seem possible. You really need to define and call the C function above.
这篇关于在python中断开UDP套接字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文