探测端口!
我现在知道一个IP 61.203.487.84 和一个端口 123
要怎样使得这个探测的时间很短 不至于让用户等得不耐烦
下面是我的代码!
foreach (DataGridViewRow row in this.Dgvdete.Rows)
{
string ips= row.Cells[0].Value.ToString();
string port= row.Cells[1].Value.ToString();
IPAddress ip = IPAddress.Parse(ips);
DataGridViewImageCell imgcell = (DataGridViewImageCell)row.Cells[2];
imgcell.Value = imageList1.Images[1];
try
{
IPEndPoint point = new IPEndPoint(ip, Convert.ToInt32(port));
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sock.SendTimeout = 1;
sock.Connect(point);
imgcell.Value = imageList1.Images[0];
//Execute(string dosCommand, int milliseconds)
}
catch
{
imgcell.Value = imageList1.Images[1];
}
}
我现在的问题是当一个端口没有开发的时候!在探测的时候要等一段时间大约是(30多秒)
我该怎样使得它的探测时间在1到2秒!