title: How to prevent DOS attacks on my http server which written in node.js?
body: <p>using node.js, the net module for building a tcp server which can hande http requests.</p>
  
  <p>I would like to prevent dos attacks so what I have done is somthing like this:</p>
  
  <pre><code>if (status.numOfCurrentRequests + 1 &gt;= MAX_NUM_OF_CONNECTIONS) {
      socket.end();
      return; 
  }
  </code></pre>
  
  <p>I was wondering if it is better to use :</p>
  
  <pre><code>socket.destroy();
  </code></pre>
  
  <p>from the API :</p>
  
  <blockquote>
    <p>socket.destroy() # Ensures that no more I/O activity happens on this
    socket. Only necessary in case of errors (parse error or so).</p>
  </blockquote>
  
  <p>what are the differences and benefits? </p>