简体   繁体   English

断开python中的UDP套接字?

[英]Disconnect UDP socket in python?

I need to 'disconnect' a UDP socket in python(and not close it!). 我需要在python中“断开” UDP套接字(而不是关闭它!)。

Is it possible to do the equivalent of: 是否有可能做到以下几点:

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)));
}

taken from here in python without interfacing the function? 取自这里的蟒蛇没有接口的功能?

Looking at socketmodule.c in the Python 2.7 sources, it doesn't seem possible. 在Python 2.7源代码中查看socketmodule.c,似乎不太可能。 You really need to define and call the C function above. 您确实需要定义并调用上面的C函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM