<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Raw socket options looks like it should be the answer, but I'm
not getting good results:</p>
<p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63">worker@10.138.69.63</a>)28> {:ok, s} =
:gen_tcp.connect('localhost', 80, [{:raw, 6, 15,
<<1>>}, {:ip, {10, 138, 69, 63}}])</p>
<p>{:ok, #Port<0.12110>}</p>
<p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63">worker@10.138.69.63</a>)29> :inet.getopts(s, [{:raw, 6, 15,
32}])</p>
<p>{:ok, []} <== option not set?<br>
</p>
<p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63">worker@10.138.69.63</a>)29> {:ok, s} =
:gen_tcp.connect('localhost', 80, [{:raw, 6, 15,
<<1>>}, {:ip, {10, 138, 69, 64}}]) </p>
<p>** (MatchError) no match of right hand side value: {:error,
:eaddrnotavail}</p>
<p><br>
</p>
<p>It appears that the IP_FREEBIND option is simply not set. If I
use IP_TRANSPARENT instead:</p>
<p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63">worker@10.138.69.63</a>)35> {:ok, s} =
:gen_tcp.connect('localhost', 80, [{:raw, 6, 19,
<<1>>}, {:ip, {10, 138, 69, 63}}])</p>
<p>{:ok, #Port<0.12113>}</p>
<p>iex(<a class="moz-txt-link-abbreviated" href="mailto:worker@10.138.69.63">worker@10.138.69.63</a>)34> :inet.getopts(s, [{:raw, 6, 19,
32}])</p>
<p>{:ok, [{:raw, 6, 19, <<0, 0, 0, 0>>}]}</p>
<p><br>
</p>
<p>In this case, the raw option 19 (IP_TRANSPARENT) is set, but to
false rather than true. I believe this is because the beam file
needs root or CAP_NET_ADMIN.</p>
<p>Any thoughts?</p>
<p><br>
</p>
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 2017-10-16 01:18 PM, Guilherme
Andrade wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAA5f+NXdxxHJWLWkeQWE3kSzWGyMUyvM_SkZFrHcB_2DGyfhgA@mail.gmail.com">
<div dir="ltr">I believe you can use raw socket options[1] for
that, but it won't be portable.<br>
<br>
[1]: <a href="http://erlang.org/doc/man/inet.html#setopts-2"
moz-do-not-send="true">http://erlang.org/doc/man/inet.html#setopts-2</a>
- {raw, Protocol, OptionNum, ValueBin}<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 16 October 2017 at 15:09, Michael L
Martin <span dir="ltr"><<a
href="mailto:mmartin4242@gmail.com" target="_blank"
moz-do-not-send="true">mmartin4242@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
Is there a way to specify the FREEBIND option when opening a
socket? I don't see any reference to it in the
documentation.<br>
<br>
<br>
Thanks,<br>
<br>
______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank"
moz-do-not-send="true">erlang-questions@erlang.org</a><br>
<a
href="http://erlang.org/mailman/listinfo/erlang-questions"
rel="noreferrer" target="_blank" moz-do-not-send="true">http://erlang.org/mailman/list<wbr>info/erlang-questions</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">Guilherme<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>