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

Peter Morgan peter.james.morgan@REDACTED
Thu Apr 7 16:14:31 CEST 2016


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.






More information about the erlang-questions mailing list