Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.

Port number from listen address

Skip to first unread message

Roy Hann

Mar 13, 2023, 1:14:12 PM3/13/23
Now that a listen address can have a "subport" number up to 15
(formerly only up to 7), how is it hashed to an IP port number?

I could just set one up to see where the extra bit pops up, but if
someone knows off the top of their head...


Roy Hann

Mar 13, 2023, 5:11:10 PM3/13/23
I went ahead and set one up. It turns out to be about as complicated as
you might guess.

Before I describe the change, there is a weird presentation of the
old port number hash at
There is a better presentation including C code at The
latter explanation makes it clear the hash starts by setting bit 14,
then additional bits are turned on depending on the listen address.

In the new method, if the subport is less than or equal to 7 then bit 14
is still set to 1. But if the subport is greater than 7 then
bit 15 is set to 1 instead. The low-order three bits are set to
whatever the subport is, masked with 0x07. (So if it's 8 the low order
three bits are 000; if it is 10 the low order three bits are 010,

0 new messages