问题
I need to 'disconnect' a UDP socket in python(and not close it!).
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?
回答1:
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.
来源:https://stackoverflow.com/questions/16828171/disconnect-udp-socket-in-python