<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Multicast in erlang is kind of weird. </div>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. <div><br></div><div>Mc = multicast address</div><div>Src = source ip of local interface</div><div><br></div><div>Windows:</div><div><pre><div id="LC987" class="line"><span class="p">{</span><span class="n">ok</span><span class="p">,</span> <span class="nv">SockSrc</span><span class="p">}</span> <span class="o">=</span> <span class="nn">gen_udp</span><span class="p">:</span><span class="n">open</span><span class="p">(</span><span class="nv">Port</span><span class="p">,</span> <span class="p">[{</span><span class="n">reuseaddr</span><span class="p">,</span><span class="n">true</span><span class="p">},</span> <span class="p">{</span><span class="n">ip</span><span class="p">,</span> <span class="nv">Src</span><span class="p">},</span> <span class="p">{</span><span class="n">multicast_ttl</span><span class="p">,</span> <span class="mi">1</span><span class="p">},</span> <span class="p">{</span><span class="n">multicast_loop</span><span class="p">,</span> <span class="n">false</span><span class="p">},</span> <span class="n">binary</span><span class="p">]),</span></div><div id="LC989" class="line"><span class="nn">inet</span><span class="p">:</span><span class="n">setopts</span><span class="p">(</span><span class="nv">SockSrc</span><span class="p">,</span> <span class="p">[{</span><span class="n">add_membership</span><span class="p">,</span> <span class="p">{</span><span class="nv">Mc</span><span class="p">,</span> <span class="nv">Src</span><span class="p">}}]);</span></div></pre><div><br></div><div><pre><div id="LC992" class="line"><span class="n">linux,</span><span class="n">freebsd:</span></div><div id="LC992" class="line"><span class="n"><br></span></div><div id="LC993" class="line"><span class="p">{</span><span class="n">ok</span><span class="p">,</span> <span class="nv">SockSrc</span><span class="p">}</span> <span class="o">=</span> <span class="nn">gen_udp</span><span class="p">:</span><span class="n">open</span><span class="p">(</span><span class="nv">Port</span><span class="p">,</span> <span class="p">[{</span><span class="n">reuseaddr</span><span class="p">,</span><span class="n">true</span><span class="p">},</span> <span class="p">{</span><span class="n">ip</span><span class="p">,</span> <span class="p">{</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">}},</span> <span class="p">{</span><span class="n">add_membership</span><span class="p">,</span> <span class="p">{</span><span class="nv">Mc</span><span class="p">,</span> <span class="nv">Src</span><span class="p">}},{</span><span class="n">active</span><span class="p">,</span><span class="n">true</span><span class="p">},</span> <span class="n">binary</span><span class="p">,{</span><span class="n">recbuf</span><span class="p">,</span> <span class="mi">1024</span><span class="o">*</span><span class="mi">1024</span><span class="p">}]);</span></div><div id="LC995" class="line"><span class="p"><br></span></div><div id="LC995" class="line"><span class="p">osx:</span></div><div id="LC995" class="line"><span class="p"><br></span></div><div id="LC995" class="line"><span class="p">{</span><span class="n">ok</span><span class="p">,</span> <span class="nv">SockSrc</span><span class="p">}</span> <span class="o">=</span> <span class="nn">gen_udp</span><span class="p">:</span><span class="n">open</span><span class="p">(</span><span class="nv">Port</span><span class="p">,</span> <span class="p">[{</span><span class="n">reuseaddr</span><span class="p">,</span><span class="n">true</span><span class="p">},</span> <span class="p">{</span><span class="n">ip</span><span class="p">,</span> <span class="nv">Mc</span><span class="p">},</span> <span class="p">{</span><span class="n">multicast_ttl</span><span class="p">,</span> <span class="mi">1</span><span class="p">},</span> <span class="p">{</span><span class="n">multicast_loop</span><span class="p">,</span> <span class="n">false</span><span class="p">},{</span><span class="n">recbuf</span><span class="p">,</span> <span class="mi">1024</span><span class="o">*</span><span class="mi">1024</span><span class="p">},</span> <span class="n">binary</span><span class="p">]),</span></div><div id="LC995" class="line"><span class="nn">inet</span><span class="p">:</span><span class="n">setopts</span><span class="p">(</span><span class="nv">SockSrc</span><span class="p">,</span> <span class="p">[{</span><span class="n">add_membership</span><span class="p">,</span> <span class="p">{</span><span class="nv">Mc</span><span class="p">,</span> <span class="p">{</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">}}}])</span></div></pre><div><br></div></div><div><br></div><div>Sergej</div><div><br><div><div>On 10 May 2014, at 21:37, Jörg Maushake <<a href="mailto:joerg.maushake@gmx.de">joerg.maushake@gmx.de</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="font-family: Verdana;font-size: 12.0px;">
<div>  Restarting windows does not change anything.<br>
  I deployed the code to macbook where it works.<br>
  It seems to be a windows issue</div>

<div>  otp_release: R16B03-1</div>

<div> </div>

<div><b>Gesendet:</b> Samstag, 10. Mai 2014 um 17:18 Uhr

<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Von:</b> "Gokhan Boranalp" <<a href="mailto:kunthar@gmail.com">kunthar@gmail.com</a>><br>
<b>An:</b> "Jörg Maushake" <<a href="mailto:joerg.maushake@gmx.de">joerg.maushake@gmx.de</a>><br>
<b>Cc:</b> Erlang <<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>><br>
<b>Betreff:</b> Re: [erlang-questions] windows multicast</div>

<div name="quoted-content">Restart your computer.<br>
<br>
On Sat, May 10, 2014 at 5:58 PM, "Jörg Maushake" <<a href="mailto:joerg.maushake@gmx.de">joerg.maushake@gmx.de</a>> wrote:<br>
> Hi list,<br>
> I am using erlang on windows 7.<br>
><br>
> When i start a multicast (the code is from nodefinder) like so:<br>
> Opts = [ { active, true },<br>
> { ip, {230, 0, 0, 1} },<br>
> { add_membership, { {230, 0, 0, 1}, { 0, 0, 0, 0 } } },<br>
> { multicast_loop, true },<br>
> { reuseaddr, true },<br>
> list<br>
> ],<br>
> { ok, RecvSocket } = gen_udp:open (4321, Opts),<br>
><br>
> i get this {error,eaddrnotavail}<br>
><br>
> Removing the tuple { ip, {230, 0, 0, 1} } from Opts seems to work!<br>
> But when i then start another node on the same machine the error i get is:<br>
> {error,eaddrinuse}<br>
><br>
> (The multicast group and port works with java )<br>
><br>
> Any suggestions ?<br>
><br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
<br>
<br>
<br>
--<br>
BR,<br>
\|/ Kunthar</div>
</div>
</div>
</div></div>
_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote></div><br></div></div></body></html>