You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, a UDP socket seems to accept any received multicast broadcast that is (1) in the list of multicast addresses on the interface and (2) has an open socket with a matching port (socket/udp.rs:373). Moreover, each incoming packet is given to the first socket that accepts it (iface/interface.rs:2489).
As a result, a client is unable to join two different multicast streams on separate addresses that share the same port. One can use a single socket to receive all the packets from each stream combined and then filter them on the client side, but the recv function only returns the IpEndpoint of the host that sent the packet and not the multicast address that the packet was sent to.
The way this works in the standard library, socket2, and most other socket apis is that the multicast group join is done as a socket-level option, rather than on the interface as a whole. Then the OS handles the group memberships across all of the sockets and makes sure that each socket that has joined the group gets a copy of the data.
I was able to hack around this in my own fork by removing the is_multicast check in udp.rs and then bind-ing the socket to the multicast address itself to at least get the packets filtered to the right sockets.
Let me know if this is expected/wanted behavior and I just fell into a weird use case. I'd be willing to put together a PR with a more comprehensive fix if there is interest. Thanks!
The text was updated successfully, but these errors were encountered:
Currently, a UDP socket seems to accept any received multicast broadcast that is (1) in the list of multicast addresses on the interface and (2) has an open socket with a matching port (socket/udp.rs:373). Moreover, each incoming packet is given to the first socket that accepts it (iface/interface.rs:2489).
As a result, a client is unable to join two different multicast streams on separate addresses that share the same port. One can use a single socket to receive all the packets from each stream combined and then filter them on the client side, but the
recv
function only returns theIpEndpoint
of the host that sent the packet and not the multicast address that the packet was sent to.The way this works in the standard library, socket2, and most other socket apis is that the multicast group join is done as a socket-level option, rather than on the interface as a whole. Then the OS handles the group memberships across all of the sockets and makes sure that each socket that has joined the group gets a copy of the data.
I was able to hack around this in my own fork by removing the
is_multicast
check inudp.rs
and thenbind
-ing the socket to the multicast address itself to at least get the packets filtered to the right sockets.Let me know if this is expected/wanted behavior and I just fell into a weird use case. I'd be willing to put together a PR with a more comprehensive fix if there is interest. Thanks!
The text was updated successfully, but these errors were encountered: