UDP socket disconnect problem
dave jones
s.dave.jones at gmail.com
Tue Sep 28 10:25:21 UTC 2010
Hello,
In Linux, I can disconnect the socket using:
sa.sin_family = AF_UNSPEC;
val = connect(sockfd, (struct sockaddr *)&sa, sizeof(sa));
the return value of val is 0; on freebsd, the return value of connect() is -1.
According to Linux's connect(2) man page:
Connectionless sockets may dissolve
the association by connecting to an address with the sa_family member
of sockaddr set to AF_UNSPEC
but FreeBSD's connect says:
Datagram sockets may dissolve the association by connecting
to an invalid address, such as a null address.
I try to convert above code to
memset(&sa, 0, sizeof(sa));
sa.sin_addr.s_addr = htonl(INADDR_ANY);
val = connect(sockfd, (struct sockaddr *)&sa, sizeof(sa));
the return value of val still -1. Any idea? Thanks.
Regards,
Dave.
More information about the freebsd-net
mailing list