binding by different process on the same port
Willem Jan Withagen
wjw at digiware.nl
Tue Dec 20 16:49:47 UTC 2016
On 18-12-2016 20:21, Willem Jan Withagen wrote:
> On 18-12-2016 16:50, Jan Knepper wrote:
>> I would guess
>>
>>> wjw ceph-osd-0 93336 43 tcp4 127.0.0.1:6804 *:*
>>
>> was started first. Claiming a specific port on a specific IP address...
>
> Well I've been trying to recreate the situation with a fake server
> programs, one binds on localhost:port and the other on 0.0.0.0:port. And
> the order does not matter, but I have not (yet) been able to actually
> register on a port for the second time.
>
> So it needs a bit more than just:
> socket, bind, listen, accept
'mmmm,
There is SO_REUSEPORT, which explains the exact behaviour of what is
going on:
SO_REUSEPORT allows completely duplicate bindings by multiple processes
if they all set SO_REUSEPORT before binding the port. This option
permits multiple instances of a program to each receive UDP/IP i
multicast or broadcast datagrams destined for the bound port.
But the flag is not explicitly set in the code.
But there is a LOT of info on the net about Linux <> FreeBSD on
SO_REUSE{ADRR,PORT}.
So i guess that I have enough things to read over X-mas.
--WjW
More information about the freebsd-hackers
mailing list