Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* binding to a multicast address with multiple listeners
@ 2003-04-25  1:51 wrapper
  2003-04-30 19:37 ` Vladislav Yasevich
  0 siblings, 1 reply; 2+ messages in thread
From: wrapper @ 2003-04-25  1:51 UTC (permalink / raw)


I do not have a copy of Stevens' Network Programming Book, but I am
nonetheless curious about why binding to a multicast address is a bad
idea.  I have the situation in my multicast application whereby
multiple sockets are bound to the same multicast port (say 8000) with
INADDR_ANY for the bind() address parameter.  The sockets then each
join a different multicast group.  However, all the sockets receive
any multicast traffic aimed at that port, even multicast traffic for
an address that was not the multicast group the socket joined.  As I
understand, joining the multicast group only tells the IP layer to
accept network traffic for a certain multicast address.  It does not
tell the UDP layer to deliver that data to the appropriate socket. 
Therefore, it would seem bind is the way in which the operating system
filters the multicast data so it knows what socket to deliver the data
to.  Without a multicast bind it seems there is no way to have
multiple sockets listen to the same port for different destination
addresses at the same time.  (Putting multicast data on the same port
is done because of network configuration reasons where my application
is to be used.  A router bridges two networks and only allows
multicast data through on a certain port.)  So why is a multicast bind
a bad idea?  It seems to be the only way to discriminate traffic sent
to the port.  In theory it seems possible that any unicast data aimed
at the port could be picked up by a socket bound with INADDR_ANY so
there would even be more potential for confusion as far as the socket
is concerned.  What am I missing?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: binding to a multicast address with multiple listeners
  2003-04-25  1:51 binding to a multicast address with multiple listeners wrapper
@ 2003-04-30 19:37 ` Vladislav Yasevich
  0 siblings, 0 replies; 2+ messages in thread
From: Vladislav Yasevich @ 2003-04-30 19:37 UTC (permalink / raw)


Well..., binding to a multicast address is not a "bad" idea, you just
have to be carefull on how you use such sockets.

In general, binding a socket to an address causes the local endpoint
to be set to that address.  Subsequent transmittions will use this
address as source.  However, a lot of multicast applications
use shortcuts of using multicast bound sockets for sends.  Strictly
speaking, such sends should fail according to protocol specifications.
However, customers have convinced some vendors to put in hacks that
will pick a unicast address on such sends.  Now, for applications to
be portable, other vendors have to provide similar hacks.

Having just written such a hack for Tru64, I can say that it is not
pretty and is against protocol definitions.

The correct way to program multicast applications is to have a
receiver socket that joined a multicast group (an maybe bound to a
multicast address) and a separate sender socket.  If you join multiple
groups, you can have multiple recievers, but can get away with only one
sender depending on your application.

-vlad

wrapper wrote:
> I do not have a copy of Stevens' Network Programming Book, but I am
> nonetheless curious about why binding to a multicast address is a bad
> idea.  I have the situation in my multicast application whereby
> multiple sockets are bound to the same multicast port (say 8000) with
> INADDR_ANY for the bind() address parameter.  The sockets then each
> join a different multicast group.  However, all the sockets receive
> any multicast traffic aimed at that port, even multicast traffic for
> an address that was not the multicast group the socket joined.  As I
> understand, joining the multicast group only tells the IP layer to
> accept network traffic for a certain multicast address.  It does not
> tell the UDP layer to deliver that data to the appropriate socket. 
> Therefore, it would seem bind is the way in which the operating system
> filters the multicast data so it knows what socket to deliver the data
> to.  Without a multicast bind it seems there is no way to have
> multiple sockets listen to the same port for different destination
> addresses at the same time.  (Putting multicast data on the same port
> is done because of network configuration reasons where my application
> is to be used.  A router bridges two networks and only allows
> multicast data through on a certain port.)  So why is a multicast bind
> a bad idea?  It seems to be the only way to discriminate traffic sent
> to the port.  In theory it seems possible that any unicast data aimed
> at the port could be picked up by a socket bound with INADDR_ANY so
> there would even be more potential for confusion as far as the socket
> is concerned.  What am I missing?



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-04-30 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-25  1:51 binding to a multicast address with multiple listeners wrapper
2003-04-30 19:37 ` Vladislav Yasevich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox