<HTML xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<HEAD><!-- Template generated by Exclaimer Template Editor on 03:54:55 Tuesday, 28 March 2017 -->
<STYLE type=text/css>P.f65e79d4-6043-4da7-a0f3-7ff94aa297b2 {
        MARGIN: 0cm 0cm 0pt
}
LI.f65e79d4-6043-4da7-a0f3-7ff94aa297b2 {
        MARGIN: 0cm 0cm 0pt
}
DIV.f65e79d4-6043-4da7-a0f3-7ff94aa297b2 {
        MARGIN: 0cm 0cm 0pt
}
TABLE.f65e79d4-6043-4da7-a0f3-7ff94aa297b2Table {
        MARGIN: 0cm 0cm 0pt
}
DIV.Section1 {
        page: Section1
}
</STYLE>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Generator" content="Microsoft Word 14 (filtered medium)" />
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</HEAD>

<BODY lang="EN-US" link="blue" vlink="purple">
<P>
<div class="WordSection1">
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D>I was also thinking about how and why Erlang puts its limit at 107 characters, but regardless of the answers, apparently I need to use 108 bytes, which seems
 to be a valid thing on Linux.<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D>Note: I need to see the number 110 passed as the 3<sup>rd</sup> parameter to the connect syscall, as opposed to 109.<o:p></o:p></span></p>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style=font-size:10.0pt;font-family:"Tahoma","sans-serif">From:</span></b><span style=font-size:10.0pt;font-family:"Tahoma","sans-serif"> Alex S. [mailto:alex0player@gmail.com]
<br />
<b>Sent:</b> Monday, March 27, 2017 8:00 PM<br />
<b>To:</b> Bekes, Andras G (IST)<br />
<b>Cc:</b> erlang-questions@erlang.org<br />
<b>Subject:</b> Re: [erlang-questions] unix domain sockets with abstract namespace: can't use all 108 bytes<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have a strong suspicion the binary might be automatically zero-terminated.<o:p></o:p></p>
<div>
<blockquote style=margin-top:5.0pt;margin-bottom:5.0pt>
<div>
<p class="MsoNormal">27 марта 2017 г., в 19:03, Bekes, Andras G написал(а):<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">Hi All,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">I need to communicate with unix domain sockets using the abstract namespace and the server (which is not under my control) opens the port with all 108 bytes of the path used.<br />
If I understand it correctly, the server/client can decide to indicate the number of actual bytes used in the 3<sup>rd</sup><span class="apple-converted-space"> </span>parameter to the bind/connect syscalls (this what Erlang does), but it is also possible to
 use all 108 bytes and fill the unused part with 0 bytes (this is what my server does).<br />
<a href="http://man7.org/linux/man-pages/man7/unix.7.html"><span style=color:purple>http://man7.org/linux/man-pages/man7/unix.7.html</span></a><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">Apparently, I can fill the path with 0 bytes up to 107 only. If I try to pass a 108-byte address to gen_tcp:connect, I get a badarg exception:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">> Sun_path_length=108.</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">108</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""> </span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">> UDS_path = <<"whatever">>.</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><<"whatever">></span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""> </span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">> Fill_length = 8*(Sun_path_length-byte_size(UDS_path)-1).</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">792</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""> </span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">> Address = {local,<<0, UDS_path/binary,0:Fill_length>>}.</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">{local,<<0,119,104,97,116,101,118,101,114,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">         0,0,0,0,0,0,0,0,0,0,0,...>>}</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""> </span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">> Port = 0.</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">0</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><br />
> gen_tcp:connect(Address,Port,[local],infinity).</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">(<0.236.0>) call gen_tcp:connect({local,<<0,119,104,97,116,101,118,101,114,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">         0,0,0,0,0,0,0,0,0,0,0,0,0>>},0,[local],infinity)</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">(<0.236.0>) call gen_tcp:connect1({local,<<0,119,104,97,116,101,118,101,114,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">         0,0,0,0,0,0,0,0,0,0,0,0,0>>},0,[local],false)</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">(<0.236.0>) call gen_tcp:try_connect([{local,<<0,119,104,97,116,101,118,101,114,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>}],0,[],false,local_tcp,{error,einval})</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">(<0.236.0>) returned from gen_tcp:try_connect/6 -> {error,einval}</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">** exception exit: badarg</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">     in function  gen_tcp:connect/4 (gen_tcp.erl, line 149)</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">(<0.236.0>) returned from gen_tcp:connect1/4 -> {error,<span style=background:yellow>einval</span>}</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">(<0.236.0>) exception_from {gen_tcp,connect,4} {exit,<span style=background:yellow>badarg</span>}</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">If I reduce the path to 107 bytes, it works. With strace, I can see the connect syscall:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">connect(19, {sa_family=AF_FILE, path=@"whatever"...},<span class="apple-converted-space"> </span><span style=background:yellow>109</span>) = -1 ECONNREFUSED (Connection refused)</span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">When I strace the official client of this server, the 3<sup>rd</sup><span class="apple-converted-space"> </span>parameter to the<span class="apple-converted-space"> </span></span><span style="font-size:11.0pt;font-family:"Courier New"">connect</span><span class="apple-converted-space"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"> </span></span><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">syscall
 is<span class="apple-converted-space"> </span><span style=background:yellow>110</span><span class="apple-converted-space"> </span>(108 + 2), regardless of the actual length of the path.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">Apparently, with Erlang it is not possible to use all 108 bytes. I should only get a badarg error at 109 bytes, not 108.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">Seems to me that this is a bug in the Erlang implementation. What do you think?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif">Thank you very much,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:11.0pt;font-family:"Calibri","sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:10.0pt;font-family:"Arial","sans-serif">Andras G. Bekes<br />
</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif">_______________________________________________<br />
erlang-questions mailing list<br />
</span><a href="mailto:erlang-questions@erlang.org"><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif";color:purple>erlang-questions@erlang.org</span></a><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif"><br />
</span><a href="http://erlang.org/mailman/listinfo/erlang-questions"><span style=font-size:9.0pt;font-family:"Helvetica","sans-serif";color:purple>http://erlang.org/mailman/listinfo/erlang-questions</span></a><o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<BR /><BR />
<HR id=HR1 />
<P></P>
<P></P>
<P></P>
<P></P></P></BODY>
</HTML>