title: listen() ignores the backlog argument?
body: <p>I have the following problem:</p>
  
  <p>I have <code>sockfd = socket(AF_INET, SOCK_STREAM, 0)</code></p>
  
  <p>After I set up and bind the socket (let's say with <code>sockfd.sin_port = htons(666)</code>), I immediately do:</p>
  
  <pre><code>listen(sockfd, 3);
  
  sleep(50); // for test purposes
  </code></pre>
  
  <p>I'm sleeping for 50 seconds to test the backlog argument, which seems to be ignored because  I can establish a connection* more than 3 times on port 666.</p>
  
  <p>*: What I mean is that I get a syn/ack for each Nth SYN (n>3) sent from the client and placed in the listen queue, instead of being dropped. What could be wrong? I've read the man pages of listen(2) and tcp(7) and found:</p>
  
  <blockquote>
    <p>The  behavior  of the backlog argument on TCP sockets changed with Linux 2.2. 
    Now it specifies the queue length for completely established sockets waiting to be accepted, instead of the number of incomplete connection requests.  The maximum length  of  the queue  for  incomplete  sockets  can 
    be  set  using
           /proc/sys/net/ipv4/tcp_max_syn_backlog.
    When  syncookies are enabled there is
    no logical maximum length and this
    setting is ignored.  See tcp(7) for
    more
           information.</p>
  </blockquote>
  
  <p>, but even with <code>sysctl -w sys.net.ipv4.tcp_max_syn_backlog=2</code> and <code>sysctl -w net.ipv4.tcp_syncookies=0</code>, I still get the same  results! I must be missing something or completely missunderstand <code>listen()</code>'s backlog purpose.</p>