Re: multicast: same port, different IP address?

From: Matt Garman
Date: Wed Apr 08 2009 - 14:43:52 EST

On Wed, Apr 8, 2009 at 1:12 PM, David Stevens <dlstevens@xxxxxxxxxx> wrote:
>> Since I'm using the address space to delineate messages, can I just
>> hard-code my port (i.e. make it always the same)?
>> Put another way: what is the effect of having one host subscribe to
>> multiple multicast streams, where each stream has the same port, but a
>> different ip address?  Is there a performance impact?
>        If any process joins a group, those will be delivered
> to any matching binds. It doesn't matter whether or not your
> process did the join.
>        You can bind to the particular multicast address and you'll
> receive only that group on that socket. For your traffic, it doesn't
> matter whether they are different ports or not in that case,
> since both the port and the address must match.
>        So, if you bind the different sockets using the multicast
> addresses and the same port, you should get the effect you're
> after, just as you would if you used INADDR_ANY and different
> ports.

Excellent, that answers my question(s) exactly. (Not to slight anyone
else, the rest of the discussion has been extremely informative!)

Is it a dangerous oversimplification to think of the port as simply an
extension of the address? E.g., you have address port 1234,
but just call it Then you can tell at a glance that
it will result in a different socket than (i.e. address port 1234). [I'm not suggesting using this nomenclature, it
just seems like an intuitive way to think about/explain it.]

Thanks again,
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at