<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 12:03:43 Maandag, 27 Maart 2017 -->
<STYLE type=text/css>P.8fbdbabb-034b-4b2b-8c4d-354935ae73cc {
MARGIN: 0cm 0cm 0pt
}
LI.8fbdbabb-034b-4b2b-8c4d-354935ae73cc {
MARGIN: 0cm 0cm 0pt
}
DIV.8fbdbabb-034b-4b2b-8c4d-354935ae73cc {
MARGIN: 0cm 0cm 0pt
}
TABLE.8fbdbabb-034b-4b2b-8c4d-354935ae73ccTable {
MARGIN: 0cm 0cm 0pt
}
DIV.Section1 {
page: Section1
}
</STYLE>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<meta name="Generator" content="Microsoft Word 14 (filtered medium)" />
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-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.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@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">Hi All,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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> 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">http://man7.org/linux/man-pages/man7/unix.7.html</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">> Sun_path_length=108.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">108<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">> UDS_path = <<"whatever">>.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><<"whatever">><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">> Fill_length = 8*(Sun_path_length-byte_size(UDS_path)-1).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">792<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">> Address = {local,<<0, UDS_path/binary,0:Fill_length>>}.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">{local,<<0,119,104,97,116,101,118,101,114,0,0,0,0,0,0,0,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> 0,0,0,0,0,0,0,0,0,0,0,...>>}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">> Port = 0.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><br />
> gen_tcp:connect(Address,Port,[local],infinity).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> 0,0,0,0,0,0,0,0,0,0,0,0,0>>},0,[local],infinity)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> 0,0,0,0,0,0,0,0,0,0,0,0,0>>},0,[local],false)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="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})<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">(<0.236.0>) returned from gen_tcp:try_connect/6 -> {error,einval}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">** exception exit: badarg<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> in function gen_tcp:connect/4 (gen_tcp.erl, line 149)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">(<0.236.0>) returned from gen_tcp:connect1/4 -> {error,<span style=background:yellow;mso-highlight:yellow>einval</span>}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">(<0.236.0>) exception_from {gen_tcp,connect,4} {exit,<span style=background:yellow;mso-highlight:yellow>badarg</span>}<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If I reduce the path to 107 bytes, it works. With strace, I can see the connect syscall:<o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">connect(19, {sa_family=AF_FILE, path=@"whatever"...},
<span style=background:yellow;mso-highlight:yellow>109</span>) = -1 ECONNREFUSED (Connection refused)<o:p></o:p></span></p>
<p class="MsoNormal">When I strace the official client of this server, the 3<sup>rd</sup> parameter to the
<span style="font-family:"Courier New"">connect</span> syscall is <span style=background:yellow;mso-highlight:yellow>
110</span> (108 + 2), regardless of the actual length of the path.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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></p>
<p class="MsoNormal">Seems to me that this is a bug in the Erlang implementation. What do you think?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you very much,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style=font-size:10.0pt;font-family:"Arial","sans-serif";color:black>Andras G. Bekes<br /></span><o:p></o:p></p>
</div>
<BR /><BR />
<HR id=HR1 />
<P></P>
<P></P>
<P></P>
<P></P></P></BODY>
</HTML>