[erlang-questions] windows multicast

Sergej Jurecko sergej.jurecko@REDACTED
Sun May 11 07:55:23 CEST 2014


Multicast in erlang is kind of weird. 
I actually have slightly different code for different platforms. This is code from r14 days. I’m not sure if it works any differently now, but I did have issues finding the right combination of parameters to get it to work. Nothing worked universally across all platforms. 

Mc = multicast address
Src = source ip of local interface

Windows:
{ok, SockSrc} = gen_udp:open(Port, [{reuseaddr,true}, {ip, Src}, {multicast_ttl, 1}, {multicast_loop, false}, binary]),
inet:setopts(SockSrc, [{add_membership, {Mc, Src}}]);

linux,freebsd:

{ok, SockSrc} = gen_udp:open(Port, [{reuseaddr,true}, {ip, {0,0,0,0}}, {add_membership, {Mc, Src}},{active,true}, binary,{recbuf, 1024*1024}]);

osx:

{ok, SockSrc} = gen_udp:open(Port, [{reuseaddr,true}, {ip, Mc}, {multicast_ttl, 1}, {multicast_loop, false},{recbuf, 1024*1024}, binary]),
inet:setopts(SockSrc, [{add_membership, {Mc, {0,0,0,0}}}])


Sergej

On 10 May 2014, at 21:37, Jörg Maushake <joerg.maushake@REDACTED> wrote:

>   Restarting windows does not change anything.
>   I deployed the code to macbook where it works.
>   It seems to be a windows issue
>   otp_release: R16B03-1
>  
> Gesendet: Samstag, 10. Mai 2014 um 17:18 Uhr
> Von: "Gokhan Boranalp" <kunthar@REDACTED>
> An: "Jörg Maushake" <joerg.maushake@REDACTED>
> Cc: Erlang <erlang-questions@REDACTED>
> Betreff: Re: [erlang-questions] windows multicast
> Restart your computer.
> 
> On Sat, May 10, 2014 at 5:58 PM, "Jörg Maushake" <joerg.maushake@REDACTED> wrote:
> > Hi list,
> > I am using erlang on windows 7.
> >
> > When i start a multicast (the code is from nodefinder) like so:
> > Opts = [ { active, true },
> > { ip, {230, 0, 0, 1} },
> > { add_membership, { {230, 0, 0, 1}, { 0, 0, 0, 0 } } },
> > { multicast_loop, true },
> > { reuseaddr, true },
> > list
> > ],
> > { ok, RecvSocket } = gen_udp:open (4321, Opts),
> >
> > i get this {error,eaddrnotavail}
> >
> > Removing the tuple { ip, {230, 0, 0, 1} } from Opts seems to work!
> > But when i then start another node on the same machine the error i get is:
> > {error,eaddrinuse}
> >
> > (The multicast group and port works with java )
> >
> > Any suggestions ?
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> >
> 
> 
> 
> --
> BR,
> \|/ Kunthar
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140511/74407f42/attachment.htm>


More information about the erlang-questions mailing list