Subject: Re: More sockets and link-local multicast questions
To: Andrew White <email@example.com>
From: Nick Amato <firstname.lastname@example.org>
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 22.214.171.124) 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 126.96.36.199.9001.
> Socket sock_en0 joins mcast group 188.8.131.52 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?