From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,f75b1bb7f6564b55 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2003-04-30 12:31:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!news.compaq.com!news.cpqcorp.net!53ab2750!not-for-mail From: Vladislav Yasevich User-Agent: Mozilla/5.0 (X11; U; OSF1 alpha; en-US; rv:1.3b) Gecko/20030318 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.unix.tru64 Subject: Re: binding to a multicast address with multiple listeners References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Wed, 30 Apr 2003 19:37:05 GMT NNTP-Posting-Host: 16.140.64.49 X-Complaints-To: abuse@HP.com X-Trace: news.cpqcorp.net 1051731425 16.140.64.49 (Wed, 30 Apr 2003 12:37:05 PDT) NNTP-Posting-Date: Wed, 30 Apr 2003 12:37:05 PDT Organization: Hewlett-Packard Company Xref: archiver1.google.com comp.unix.tru64:9854 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?