views:

140

answers:

2

Hi,

I have problems to open an multicast socket in Erlang to receive messages:

88> gen_udp:open(5353,[{reuseaddr, true}, {ip,{224,0,0,251}},{multicast_ttl,4},{multicast_loop,false},binary]).
{error,eaddrnotavail}

I checkt diffrent IP addresses and ports and the option {active, false}, but nothing helps. What could be the reason?

Thanks, Matthias.

A: 

Have you tried adding the option {add_membership, {Addr, LAddr}} where:

  1. Addr is the multicast group in question (e.g. 224.0.0.251)
  2. LAddr is a local interface (e.g. 0.0.0.0 for the default one)

1> gen_udp:open(5353,[{reuseaddr, true}, {add_membership, {{224, 0,0, 251}, {0, 0, 0, 0}}}, {ip,{224,0,0,251}},{multicast_ttl,4},{multicast_loop,false},binary]).

{ok,#Port<0.454>}

jldupont
Hi, thanks for the quick answer! No positive effect :-(Is this a router or a local computer problem?Regards, Matthias
Matthias
what are the symptoms?
jldupont
But OK, if I try this... (see below) I get a new error with a new hint about the possible problem. Thanks!99> gen_udp:open(5353,[{reuseaddr, true},{add_membership, {{224, 0,0, 251}, {0, 0, 0, 0}}},{multicast_ttl,4},{multicast_loop,false},binary]).{error,eaddrinuse}
Matthias
if this is on OSX or Windows running Bonjour you are not going to be able to send on 5353. I can open and listen on 5353 but I still have not beem able to send on that port from Erlang.http://github.com/fuzzylollipop/inet_mdns/blob/master/src/inet_mdns.erl
fuzzy lollipop
@fuzzy: Zeroconf/Bonjour might tie up this port and not share it: I wouldn't expect anything different. Running different servers on the same port would be sort of confusing to say the least.
jldupont
With your first tip, the symptoms are the same {error,eaddrnotavail}on my Windows XP. Also, another port or another multicast IP does not help.
Matthias
@Matthias: have you quit Bonjour instances?
jldupont
Yes all. I killed additionally the virus scanner and firewall ... but I still have the same problem, also with other multicast IP addresses like (224.1.2.3) and with other ports like 1234.
Matthias
I am running out of ideas... many sorries.
jldupont
A: 

Hi,

After your helpful comments, I test something new. Please have a look:

12> gen_udp:open(1234,[{reuseaddr,true}, {add_membership,{{224,0,0,1},{0,0,0,0}}}, {ip,{224,0,0,1}}, {multicast_ttl,4}, {multicast_loop,false}, binary]).
{error,eaddrnotavail}
13> gen_udp:open(1234,[{reuseaddr, true}, {add_membership,{{224,0,0,1},{0,0,0,0}}},{multicast_ttl,4}, {multicast_loop,false}, binary]).
{ok,#Port<0.474>}

What's wrong? I think I need to get the line 12> running. Is the line 13> sufficient to write a listener.

Thanks, Matthias

Matthias