Re: BSD socket oddity with SO_REUSEADDR
Re: BSD socket oddity with SO_REUSEADDR
- Subject: Re: BSD socket oddity with SO_REUSEADDR
- From: "Justin C. Walker" <email@hidden>
- Date: Tue, 15 Jul 2003 10:45:41 -0700
On Tuesday, July 15, 2003, at 07:45 AM, Aaron Ballman wrote:
I am doing a socket implementation using native BSD sockets on OS X
(10.2.6), and have run into a rather odd quirk. It seems as though
SO_REUSEADDR isn't functioning properly. First, I create the socket's
file descriptor with a call to socket, then I try to set the
SO_REUSEADDR socket option with setsockopt. That call returns 0
(success), and just because I was being paranoid, I call getsockopt to
make sure the flag was set (and it was). Yet I am still getting an
EADDRINUSE error from errno on a call to bind (on a subsequent bind
attempt).
[snip]
I don't see a problem on 10.2.6, nor have I seen any on previous
versions of Mac OS X. You haven't shown enough detail to isolate the
problem you are having. I have a couple of questions to help narrow
the search space:
1) Does this problem occur all the time?
2) Is gdb in the picture (i.e., are you debugging; if so, does the
problem
show up without gdb)?
3) Do you see the problem if you kill the server before connecting to
it?
4) Has this code run on other BSDs? Winsock was close to BSD at one
point,
but I suspect that's no longer the case; and the others bear no
relation
to the BSD heritage.
If you haven't looked at it, you might consider Stevens's "Unix Network
Programming", V1, 2nd Ed (Prentice Hall). He covers the use of
SO_REUSEADDR and SO_REUSEPORT in some detail (typically, the latter is
for multicast apps).
Also, his website (
http://www.kohala.com) has a tarball of network code
from this book. If I run some of the client/server examples from that
collection, it works just fine, over and over.
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | It's not whether you win or
lose...
| It's whether *I* win or lose.
*--------------------------------------*-------------------------------*
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.