[erlang-questions] udp multicast: problem with OSX?

Peter Morgan peter.james.morgan@REDACTED
Tue Apr 12 18:06:36 CEST 2016


Hi Torben, Max,

On OSX I can receive multicast traffic using the following options (the same as Max’s pretty much):

    [binary,
     inet,
     {reuseaddr, true},
     {ip, MulticastAddress},
     {multicast_ttl, 4},
     {multicast_loop, true},
     {add_membership, {MulticastAddress, {0, 0, 0, 0}}},
     {active, once}].

Where MulticastAddress is {224, 0, 0, 251}. I’m using that address because it is one used by OSX, Linux/everything for multicast DNS :)

On OSX I can happily receive multicast traffic on a gen_udp socket that is opened with the above parameters.

However, on OSX I cannot send to the same socket using:

    gen_udp:send(Socket, MulticastAddress, Port, SomeMessage).

On Linux (Fedora 23) the above send does work. On OSX I get {error, eaddrnotavail} on send.

I’m sure I have had this working on OSX and Linux together, so I’m probably doing some rather stupid…

OSX is El Capitan (10.11.4 beta). Erlang is 18.3 (brew).

I’ve tried replacing the {0, 0, 0, 0} in {add_membership, {MulticastAddress, {0, 0, 0, 0}}} with IP address of the interface, but it didn’t make any difference.

Thanks,
Peter.




> On 11 Apr 2016, at 16:58, Max Lapshin <max.lapshin@REDACTED> wrote:
> 
> This is how it is working for me:
> 
>   {ok, Addr} = inet_parse:address(Host),
>   Common = [binary,{reuseaddr,true},{recbuf,2*1024*1024},inet,{ip,Addr},{read_packets,100}],
>   Options = case is_multicast(Addr) of
>     true ->
>       Multicast = [{multicast_ttl,4},{multicast_loop,true},{add_membership,{Addr,GwIP}}],
>       Common ++ Multicast;
>     false ->
>       Common
>   end,
> 




More information about the erlang-questions mailing list