title: Client closed after sending a message, why gen_tcp with opts {active, false} accept twice
body: <p>I just do a testing with gen_tcp.  One simple echo server, and one client.</p>
  
  <p>But client started and closed, server accept two connection, and one is ok, the other is bad.  </p>
  
  <p>Any issue of my demo script, and how to explain it?</p>
  
  <h1>server</h1>
  
  <pre class="lang-erlang prettyprint-override"><code>-module(echo).
  -export([listen/1]).
  
  -define(TCP_OPTIONS, [binary, {packet, 0}, {active, false}, {reuseaddr, true}]).
  
  listen(Port) -&gt;
      {ok, LSocket} = gen_tcp:listen(Port, ?TCP_OPTIONS),
      accept(LSocket).
  
  accept(LSocket) -&gt;
      {ok, Socket} = gen_tcp:accept(LSocket),
      spawn(fun() -&gt; loop(Socket) end),
      accept(LSocket).
  
  loop(Socket) -&gt;
      timer:sleep(10000),
      P = inet:peername(Socket),
      io:format("ok ~p~n", [P]),
      case gen_tcp:recv(Socket, 0) of
          {ok, Data} -&gt;
              gen_tcp:send(Socket, Data),
              loop(Socket);
          {error, closed} -&gt;
              ok;
          E -&gt;
              io:format("bad ~p~n", [E])
      end.
  </code></pre>
  
  <p>Demo Server</p>
  
  <pre class="lang-erlang prettyprint-override"><code>1&gt; c(echo).
  {ok,echo}
  2&gt; echo:listen(1111).
  ok {ok,{{192,168,2,184},51608}}
  ok {error,enotconn}
  </code></pre>
  
  <h1>Client</h1>
  
  <pre class="lang-erlang prettyprint-override"><code>&gt; spawn(fun() -&gt; {ok, P} = gen_tcp:connect("192.168.2.173", 1111, []), gen_tcp:send(P, "aa"), gen_tcp:close(P) end).
  &lt;0.64.0&gt;
  </code></pre>
  
  <p>```</p>