Executing TcpClient.BeginConnect ten thousands of times at once -good idea?

  • Thread starter Thread starter PSiegmann
  • Start date Start date
P

PSiegmann

Hi.

I am working on a simple port scanner. Since TcpClient.Connect() takes
alot of time until it gives an exception that it couldn't connect to a
port, I envisioned something different:

I want to execute TcpClient.BeginConnect (the asynchronous function)
65.000 times AT ONCE (to scan the ports 1 to 65.000). Well nearly at
once (in a for loop that counts from 1 to 65.000)

That means I can get 65.000 exceptions too.


So, how good of an idea is that? Can it crash the computer? Memory
overflow? Network crash?

Never tried to do something that stupid.
 
Seeing as how there are only 50 threads available in the ThreadPool by
default, you aren't likely to get very far.
Peter
 
Back
Top