Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Oct 2010 13:18:42 +0200
From:      =?UTF-8?Q?Marius_N=C3=BCnnerich?= <marius@nuenneri.ch>
To:        dave jones <s.dave.jones@gmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: UDP socket disconnect problem
Message-ID:  <AANLkTikDvO1zxsMEwtpXqvoTzK7GDYD2bYqzgByB7X1D@mail.gmail.com>
In-Reply-To: <AANLkTimkODMHMfLB-M6gsDRoh6yVJ0SG9zqiyX%2BWC4u4@mail.gmail.com>
References:  <AANLkTimkODMHMfLB-M6gsDRoh6yVJ0SG9zqiyX%2BWC4u4@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Sep 28, 2010 at 11:58, dave jones <s.dave.jones@gmail.com> wrote:
> Hello,
>
> In Linux, I can disconnect the socket using:
> sa.sin_family =3D AF_UNSPEC;
> val =3D connect(sockfd, (struct sockaddr *)&sa, sizeof(sa));
>
> the return value of val is 0; on freebsd, the return value of connect() i=
s -1.
> According to Linux's connect(2) man page:
>
> Connectionless sockets may dissolve
> the association by connecting to an address with the =C2=A0sa_family =C2=
=A0member
> of sockaddr set to AF_UNSPEC
>
> but FreeBSD's connect says:
> Datagram sockets may dissolve the association by connecting
> =C2=A0to 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 =3D htonl(INADDR_ANY);
> val =3D 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()?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikDvO1zxsMEwtpXqvoTzK7GDYD2bYqzgByB7X1D>