Subject: Re: Multicast oddity
To: Bill Studenmund <wrstuden@netbsd.org>
From: Greg Troxel <gdt@ir.bbn.com>
List: tech-net
Date: 04/29/2005 19:58:13
  My confusion is that I received a request on socket X and grabbed the peer 
  address. When I go to send back to that peer address on socket X, I get a 
  failure sending. When I use a different socket (not in a multicast group) 
  with what seems like the exact same addresses, it works.

I don't see a need to have two sockets.  Are you checking all the
syscall returns, in particular the second bind (SO_REUSEADDR?)?
Try with just one socket.

  No... Sorry. That's I have the "multicast" socket bound to address 
  unspecified, port 427, which has joined the right multicast group.

This is redundant with the socket bound to unspecified/427 and not
joined.

  I agree it seems broken. Does transmitting a packet over loopback set the 
  "sender" address to that of loopback?

<asbestos>Well, I suppose it probably depends if you have a strong ES
or a weak ES.</> But yes, on normal NetBSD, if the packet is from a
socket on the same host, and lo0 is selected since you are
transmitting to localhost, the source address should end up 127.0.0.1,
and that should show up in recvfrom as 127.0.0.1.  But that's quite
distinct from 0.0.0.0, which makes no sense as a source address.

  I'll double-check I didn't bork something else and that my printfs are 
  right...

Watch out for static buffers in inet_ntoa and using the function twice
in one printf.

-- 
        Greg Troxel <gdt@ir.bbn.com>