我需要在 python 中“断开”一个 UDP 套接字(而不是关闭它!)。
是否有可能做等同于:
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)));
}
取自here在 python 中没有接口(interface)函数?
最佳答案
查看 Python 2.7 源代码中的 socketmodule.c,似乎不可能。您确实需要定义并调用上面的 C 函数。
关于python - 在python中断开UDP套接字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16828171/