Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Nov 2013 09:59:26 -0800
From:      Tim Kientzle <kientzle@freebsd.org>
To:        =?windows-1252?Q?Ermal_Lu=E7i?= <eri@freebsd.org>
Cc:        freebsd-net <freebsd-net@freebsd.org>, "freebsd-current@freebsd.org" <freebsd-current@freebsd.org>
Subject:   Re: [PATCH] SO_REUSEADDR and SO_REUSEPORT behaviour
Message-ID:  <4053E074-EDC5-49AB-91A7-E50ABE36602E@freebsd.org>
In-Reply-To: <CAPBZQG29BEJJ8BK=gn%2Bg_n5o7JSnPbsKQ-=3=6AkFOxzt%2B=wGQ@mail.gmail.com>
References:  <CAPBZQG29BEJJ8BK=gn%2Bg_n5o7JSnPbsKQ-=3=6AkFOxzt%2B=wGQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Nov 29, 2013, at 4:04 AM, Ermal Lu=E7i <eri@freebsd.org> wrote:

> Hello,
>=20
> since SO_REUSEADDR and SO_REUSEPORT are supposed to allow two daemons =
to
> share the same port and possibly listening ip =85

These flags are used with TCP-based servers.

I=92ve used them to make software upgrades go more smoothly.
Without them, the following often happens:

* Old server stops.  In the process, all of its TCP connections are =
closed.

* Connections to old server remain in the TCP connection table until the =
remote end can acknowledge.

* New server starts.

* New server tries to open port but fails because that port is =93still =
in use=94 by connections in the TCP connection table.

With these flags, the new server can open the port even though
it is =93still in use=94 by existing connections.


> This is not the case today.
> Only multicast sockets seem to have the behaviour of broadcasting the =
data
> to all sockets sharing the same properties through these options!

That is what multicast is for.

If you want the same data sent to all listeners, then
that is multicast behavior and you should be using
a multicast socket.

> The patch at [1] implements/corrects the behaviour for UDP sockets.

You=92re trying to turn all UDP sockets with those options
into multicast sockets.

If you want a multicast socket, you should ask for one.

Tim




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4053E074-EDC5-49AB-91A7-E50ABE36602E>