Subject: Re: More sockets and link-local multicast questions
To: Andrew White <firstname.lastname@example.org>
From: Nick Amato <email@example.com>
Date: 10/10/2001 22:19:07
On Thu, Oct 11, 2001 at 11:40:22AM +1000, Andrew White wrote:
> I'm seeing some "features" in my programs using sockets and link-local
> multicast, and would like some assistance. The symptoms are identical on
> NetBSD 1.5 and FreeBSD (i386), and almost identical on Darwin 1.3.7 (under
> IPv4 only), so I expect the errors are my own.
> The aim:
> Pick a link-local multicast address (say 184.108.40.206) and port (say 9001).
> Listen on that address and port on each interface, and receive messages from
> that interface. Most important, associate the received message with the
> interface without using the source address / routing table.
> My current technique is:
> Create one socket per interface (say 2: en0 and en1).
> Bind (with REUSEPORT) each socket to 220.127.116.11.9001.
> Socket sock_en0 joins mcast group 18.104.22.168 on en0. sock_en1 does the
> same on en1.
> Problem: packets received on either en0 or en1 are delivered to both
> What is the correct way to do this?
Shouldn't you be using:
setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
after using bind(2) to attach to port 9001?