title: Blocking connection flood
body: <p><strong>Problem:</strong></p>
  
  <p>Assuming my application gets flooded with connection attempts (attempted DDoS attack) and I want to ignore any traffic and connection attempts from some endpoint from now on, what would be the best place to filter?</p>
  
  <p><strong>Use Case:</strong></p>
  
  <p>In my application I'm using an System.Net.TcpListener to listen for incoming connections.
  My naive approach would be to just accept all connections, check the endpoint and then possibly close the connection instantly.</p>
  
  <p>Something tells me that that can't be very efficient. Even just the creation of the TcpClient while accepting alone in my application will consume resources.</p>
  
  <p>So what can I do to reliably reject connections from some endpoint/ip while expending minimal resources to do so on Windows? What about the same situation on Linux systems? </p>
  
  <p>On Linux there's "iptables", is that as efficient as it gets?
  And on Windows one could use the built-in firewall system.</p>
  
  <p>Are there any other ways to block connections from an ip in software that might be even more efficient? If so what are those? </p>
  
  <p><strong>Hardware Firewalls:</strong></p>
  
  <p>Please do not try to mention hardware firewalls and filters. I am aware of them and know they are made for this purpose, but this question is explicitly about the software side of things.</p>