multicast join problems (source specific)

Sergej Jurečko sergej.jurecko@REDACTED
Wed Jan 20 09:54:16 CET 2021


Try connecting to multicast like so (Mc is multicast IP, Src is local IP):

{ok, SockSrc} = gen_udp:open(Port, [{reuseaddr,true},
{ip, {0,0,0,0}}, {add_membership, {Mc, Src}},{active,true}, binary,{recbuf,
1024*1024}]);

Or maybe

{ok, SockSrc} = gen_udp:open(Port, [{reuseaddr,true},
{ip, Src}, {multicast_ttl, 1}, {multicast_loop, false}, binary]),
inet:setopts(SockSrc, [{add_membership, {Mc, Src}}]);

On Mon, Jan 18, 2021 at 10:20 PM Mark Geib <mark.geib.44@REDACTED> wrote:

> I have a problem when joining more than one source specific multicast
> group. The first gen_udp:open() works as expected, I start receiving
> datagrams sent to the specified multicast address, and coming from the
> specified source. However, in another gen_server if I try to do the same,
> but on a different multicast and source address, I start receiving the
> datagrams on both the new socket as well as the first socket and from both
> multicast groups. The open looks like:
>
> Port = 3100,
> Bin = << <<239,0,0,1>>/binary, <<0,0,0,0>>/binary, <<10,0,1,1>>/binary >>,
> {ok, _Socket} = gen_udp:open(Port,
>                              [binary,
>                               {active, true},
>                               {reuseaddr, true},
>                               {multicast_ttl, 30},
>                               {raw, 0, 39, Bin}]), %% 0 - IPPROTO_IP, 39 -
> IP_ADD_SOURCE_MEMBERSHIP
>
> I am able to join multiple multicasts, non source specific, and receive
> only datagrams from the correct group by using an open like:
>
> Port = 3100,
> {ok, _Socket} = gen_udp:open(Port,
>                              [binary,
>                               {active, true},
>                               {reuseaddr, true},
>                               {multicast_ttl, 30},
>                               {add_membership, {239,0,0,1}, {0,0,0,0}}]),
>
> Any suggestions or help would be appreciated.
>
> Mark.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210120/dbce6d41/attachment.htm>


More information about the erlang-questions mailing list