<div dir="ltr"><div>Try connecting to multicast like so (Mc is multicast IP, Src is local IP):</div><div><br></div><div>{ok, SockSrc} = gen_udp:open(Port, [{reuseaddr,true}, <br>                                                                                                    {ip, {0,0,0,0}}, {add_membership, {Mc, Src}},{active,true}, binary,{recbuf, 1024*1024}]);</div><div><br></div><div>Or maybe</div><div><br></div><div>{ok, SockSrc} = gen_udp:open(Port, [{reuseaddr,true}, <br>                                                                                       {ip, Src}, {multicast_ttl, 1}, {multicast_loop, false}, binary]),<br>                                     inet:setopts(SockSrc, [{add_membership, {Mc, Src}}]);</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 18, 2021 at 10:20 PM Mark Geib <<a href="mailto:mark.geib.44@gmail.com">mark.geib.44@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;">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:<div><br></div><div>Port = 3100,</div><div><font face="Andale Mono"><span style="font-style:normal">Bin = << <<239,0,0,1>>/binary, <<0,0,0,0>>/binary, <<10,0,1,1>>/binary >>,</span></font></div><div><font face="Andale Mono"><span style="font-style:normal">{ok, _Socket} = gen_udp:open(Port,<br>                             [binary,<br>                              {active, true},<br>                              {reuseaddr, true},<br>                              {multicast_ttl, 30},<br>                              {raw, 0, 39, Bin}]), %% 0 - IPPROTO_IP, 39 - IP_ADD_SOURCE_MEMBERSHIP</span></font></div><div><br></div><div><font face="Avenir-Book">I am able to join multiple multicasts, non source specific, and receive only datagrams from the correct group by using an open like:</font></div><div><font face="Avenir-Book"><br></font></div><div><div>Port = 3100,</div><div><span style="font-family:"Andale Mono"">{ok, _Socket} = gen_udp:open(Port,</span></div><div><font face="Andale Mono">                             [binary,<br>                              {active, true},<br>                              {reuseaddr, true},<br>                              {multicast_ttl, 30},<br></font></div></div><div><font face="Andale Mono">                              {add_membership, {239,0,0,1}, {0,0,0,0}}]),</font></div><div><font face="Andale Mono"><br></font></div><div><font face="Avenir-Book">Any suggestions or help would be appreciated.</font></div><div><font face="Avenir-Book"><br></font></div><div><font face="Avenir-Book">Mark.</font></div></div></blockquote></div>