I have problems to open an multicast socket in Erlang to receive messages:
88> gen_u开发者_如何学编程dp: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.
Have you tried adding the option {add_membership, {Addr, LAddr}}
where:
- Addr is the multicast group in question (e.g. 224.0.0.251)
- 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>}
精彩评论