C#でポートスキャナーを作成しようとしていますが、これまでのところ:
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 <= 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");
}
}
}
ただし、閉じたポートの場合、処理が遅く、約 20 秒かかります。プロセスを高速化するにはどうすればよいですか? どうもありがとう。