UDP socket disconnect problem
Marius Nünnerich
marius at nuenneri.ch
Wed Oct 27 11:46:05 UTC 2010
On Tue, Sep 28, 2010 at 11:58, dave jones <s.dave.jones at gmail.com> wrote:
> 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.
Just curious, why are you not using close()?
More information about the freebsd-net
mailing list