title: Speed up Port Scan C#
body: <p>I am trying to create port scanner in C#, so far I have this:</p>
  
  <pre><code>private void ip()
  {
      int start = 70;
      int end = 80;
      string ipString;
      if (this.comboBox1.Text == "Domain") {
           ipString= Dns.GetHostEntry(txtHost.Text).AddressList[0].ToString();
      }
      else {
          ipString = txtHost.Text;
      }
      TcpClient asd = new TcpClient();
      // MessageBox.Show(ipString);     
      IPAddress address = IPAddress.Parse(ipString);
      for (int i = start; i &lt;= end; i++)
      {
          try
          {
              asd.SendTimeout = 3000;
              asd.ReceiveTimeout = 3000;
              asd.Connect(address, i);
  
              if (asd.Connected)
              {
                  MessageBox.Show("Port " + i + " is open");
              }
          }
          catch
          {
              MessageBox.Show("Port " + i + " is closed");
          }
      }
  }
  </code></pre>
  
  <p>However for closed ports, it's kinda slow, around 20 seconds, what should I do to make the process faster?
  Thanks a lot.</p>