Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Sep 2010 17:58:53 +0800
From:      dave jones <s.dave.jones@gmail.com>
To:        freebsd-net@freebsd.org
Subject:   UDP socket disconnect problem
Message-ID:  <AANLkTimkODMHMfLB-M6gsDRoh6yVJ0SG9zqiyX%2BWC4u4@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimkODMHMfLB-M6gsDRoh6yVJ0SG9zqiyX%2BWC4u4>