setsockopt SO_REUSEADDR question - Unix
This is a discussion on setsockopt SO_REUSEADDR question - Unix ; Hi
I've noticed that if I create a TCP listening socket, using
setsocktopt() with the SO_REUSEADDR option set it only seems to work
if its done before bind() is called. Is this normal behaviour? Does it
apply to all setsockopt() ...
-
setsockopt SO_REUSEADDR question
Hi
I've noticed that if I create a TCP listening socket, using
setsocktopt() with the SO_REUSEADDR option set it only seems to work
if its done before bind() is called. Is this normal behaviour? Does it
apply to all setsockopt() options or just this one?
Thanks for any help
B2003
-
Re: setsockopt SO_REUSEADDR question
"Boltar" wrote in message
news:d5c0b627-ca07-4ba5-ae1f-3f85d89e042d@r66g2000hsg.googlegroups.com...
> Hi
>
> I've noticed that if I create a TCP listening socket, using
> setsocktopt() with the SO_REUSEADDR option set it only seems to work
> if its done before bind() is called. Is this normal behaviour? Does
> it
> apply to all setsockopt() options or just this one?
Yes SO_REUSEADDR only applies if set before the call to bind(), since
it controls the behaviour of bind as described in this man page
http://www.rt.com/man/bind.2.html . Similarly, the socket option
SO_LINGER must be set before you close the socket with close(), since
it controls the behaviour of close(). Most other socket options should
take effect immediately, but consult the man pages for your system to
be sure.
> Thanks for any help
You're welcome!
Mark