<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi, <br>
<br>
yes this sounds confusing. We looked into it a little bit but
couldn't find the reason for it right away. Have you tried tracing
the resv0 in prim_inet? It might give you some more information
about why this happens. We can look into it some more too when we
get the time, and if you don't find out more before that :) <br>
<br>
/ Zandra<br>
<br>
<br>
<div class="moz-cite-prefix">On 2015-02-10 14:39, Bekes, Andras G
wrote:<br>
</div>
<blockquote
cite="mid:EEDCCA33995F1A42894A53C0E0B655964D9CB791@OYWEX0205N3.msad.ms.com"
type="cite">
<!-- Template generated by Exclaimer Template Editor on 08:39:44 Tuesday, 10 February 2015 -->
<style type="text/css">P.1a39adfe-2d69-4bd9-9b41-b8a59f0904b0 {
MARGIN: 0cm 0cm 0pt
}
LI.1a39adfe-2d69-4bd9-9b41-b8a59f0904b0 {
MARGIN: 0cm 0cm 0pt
}
DIV.1a39adfe-2d69-4bd9-9b41-b8a59f0904b0 {
MARGIN: 0cm 0cm 0pt
}
TABLE.1a39adfe-2d69-4bd9-9b41-b8a59f0904b0Table {
MARGIN: 0cm 0cm 0pt
}
DIV.Section1 {
page: Section1
}
</style>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<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;
font-family:"Calibri","sans-serif";}
@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]-->
<p>
</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">Looks like I have a problem with the
erroneous result of gen_tcp:recv/2, as it returns
{error,closed} instead of my expectation of
{error,econnreset}.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I can reproduce my problem by:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">1, starting a server application and
forcing it into a busy state when it is listening but not
accepting connections<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">2,starting 1000 clients (in Erlang) that
connect to the server, filling the TCP listen backlog of the
server.<o:p></o:p></p>
<p class="MsoNormal">When the backlog is filled and after some
time (~2 minutes), the Erlang connections return
{error,closed}.<o:p></o:p></p>
<p class="MsoNormal">This is what I do in Erlang:<o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier
New"">fun()->{ok,Socket}= TCPCONNECT(HOST,PORT),<br>
ok=gen_tcp:send(Socket,<<"SOMEDATA…”>>),<br>
io:format("~p:~p\n",[self(),gen_tcp:recv(Socket,100)])<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New"">end.<o:p></o:p></span></p>
<p class="MsoNormal">spawn this 1000 times.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">3, a native client of the service however
tells me that the connection was reset by peer.<o:p></o:p></p>
<p class="MsoNormal">According to strace, it executes a recvfrom
which returns ECONNRESET:<o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier
New"">recvfrom(...) = -1 ECONNRESET (Connection reset
by peer)<o:p></o:p></span></p>
<p class="MsoNormal">I also straced the Erlang beam process and
it indeed gets an ECONNRESET result for the recvfrom call, but
the Erlang return value is {error,closed}.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Unfortunately it looks like I really need
to separate these two results.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I also tried gen_tcp in active mode, but no
difference, the result is {error,closed} instead of
{error,econnreset}.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Can someone explain why the econnreset
error is masked? Is there any way I can separate the two kinds
of events?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<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>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<hr id="HR1">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>