Subject: | Documentation is Incorrect |
Date: | Wed, 17 Apr 2019 09:17:11 -0700 |
To: | "bug-IO-Socket-Multicast [...] rt.cpan.org" <bug-IO-Socket-Multicast [...] rt.cpan.org> |
From: | Mark Dierolf <mdierolf [...] financialcontent.com> |
Hello,
I wanted to alert you to some incorrect information being provided in the documentation for IO::Socket::Multicast.
In the documentation, you write:
---
If no interface is specified, then the multicast group is joined on INADDR_ANY, meaning that multicast transmissions received on any of the host's network interfaces will be forwarded to the socket.
---
Unfortunately, this is not quite correct. When joining INADDR_ANY, the default behavior is to join an "appropriate interface":
---
http://man7.org/linux/man-pages/man7/ip.7.html (https://link.getmailspring.com/link/BD48E288-34A6-4C97-B59D-649D7FAD6147@getmailspring.com/0?redirect=http%3A%2F%2Fman7.org%2Flinux%2Fman-pages%2Fman7%2Fip.7.html&recipient=YnVnLUlPLVNvY2tldC1NdWx0aWNhc3RAcnQuY3Bhbi5vcmc%3D)
imr_multiaddr contains the address of the multicast group the appli‐
cation wants to join or leave. It must be a valid multicast address
(or setsockopt(2) fails with the error EINVAL). imr_address is the
address of the local interface with which the system should join the
multicast group; if it is equal to INADDR_ANY, an appropriate inter‐
face is chosen by the system. imr_ifindex is the interface index of
the interface that should join/leave the imr_multiaddr group, or 0 to
indicate any interface.
---
I can find no specification as to how an "appropriate interface" is chosen, however in linux it appears to be the first interface listed in the unicast routing table for the address you are joining. So that would typically be the interface of your default route
In order to listen for multicast traffic on all interfaces, you must enumerate them, join each individually, and then routinely add and remove memberships as interfaces are added and removed.
Regards,
Mark Dierolf