title: .NET Socket Listen backlog
body: <p>I have a server socket that I have configured to allow one connection at once (by blocking Accept calls with a semaphore), with a backlog queue size of 1. That is, I called .Listen(1).</p>
  
  <p>I then follow the following process:</p>
  
  <ul>
  <li>I call AcceptAsync on my server socket (only once)</li>
  <li>I have a client ConnectAsync (connects successfully)</li>
  <li>I have a client ConnectAsync (connects successfully, supposedly in the queue... a way to tell would be nice)</li>
  <li>I have a third client ConnectAsync</li>
  </ul>
  
  <p>These three ConnectAsync calls happen in rapid succession.</p>
  
  <p>The expected result for the third ConnectAsync is to have the SocketAsyncEventArgs "SocketError" property be something other than "SocketError.Success". I actually expect "SocketError.ConnectionRefused", to be specific.</p>
  
  <p>About 95% of the time, this is the case. The third client's callback gives me a SocketError value other than Success.</p>
  
  <p>Every now and then, though, the third ConnectAsync "works", in the same way the second one does. The EventArgs.SocketError gives me SocketError.Success, and the corresponding Socket.Connected property reads "true".</p>
  
  <p>What's going on? I call AcceptAsync exactly <strong>once</strong> (I have verified this carefully with breakpoints), so only one client should be accepted, and the rest should be on the backlog queue. My queue size is 1, so how is the third client connecting successfully every now and then?</p>
  
  <p>Please don't tell me to use a larger queue size. This is for a test function I've written, and not code that is actively serving clients. At this point it's more curiosity. :)</p>