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

Torben Hoffmann thoffmann@REDACTED
Mon Apr 11 13:48:14 CEST 2016


Hi Peter,

I cannot explain why it works on Fedora.

But on the Mac I think it is because 224.0.0.251 is used for Multicast
DNS.

Furthermore, when you use the {ip, Addr} option the Addr should be one
of the interfaces on your machine, not a multicast address.
And you cannot use 127.0.0.1 - I have had it working with 0.0.0.0.
Cannot remember how to change the address at the moment.

Cheers,
Torben

Peter Morgan <peter.james.morgan@REDACTED> writes:

> [ text/plain ]
> Hello -
>
> I’m having some trouble getting UDP multicast working on OSX, whereas the same code on Linux works fine.
>
> On linux (fedora 23):
>
> [pmorgan@REDACTED ~]$ erl
> Erlang/OTP 18 [erts-7.3] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
>
> Eshell V7.3  (abort with ^G)
> 1> Address = {224, 0, 0, 251}.
> {224,0,0,251}
> 2> Port = 5353.
> 5353
> 3> {ok, Socket} = gen_udp:open(Port, [binary, {ip, Address}, {add_membership, {Address, {0,0,0,0}}}, {reuseaddr, true}]).
> {ok,#Port<0.543>}
> 4> gen_udp:send(Socket, Address, Port, <<"hello world">>).
> ok
>
>
> Whereas on OSX:
>
> Office-iMac:mdns pmorgan$ sw_vers 
> ProductName:	Mac OS X
> ProductVersion:	10.11.4
> BuildVersion:	15E61b
>
> Office-iMac:mdns pmorgan$ erl
> Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
>
> Eshell V7.3  (abort with ^G)
> 1> Address = {224, 0, 0, 251}.
> {224,0,0,251}
> 2> Port = 5353.
> 5353
> 3> {ok, Socket} = gen_udp:open(Port, [binary, {ip, Address}, {add_membership, {Address, {0,0,0,0}}}, {reuseaddr, true}]).
> {ok,#Port<0.553>}
> 4> gen_udp:send(Socket, Address, Port, <<"hello world">>).
> {error,eaddrnotavail}
>
>
> I’ve tried various other options in gen_udp:open/2, but not found a combination that works for OSX. Any ideas please? The above is a simplified test case of https://github.com/shortishly/mdns/blob/master/src/mdns_udp.erl#L41-L49
>
> Thanks,
> Peter.
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-- 
Torben Hoffmann
Architect, basho.com
M: +45 25 14 05 38



More information about the erlang-questions mailing list