这是我的方法 但这个方法在检测比较多的数据的时候非常卡 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];
}
}希望哪位同行能告诉我比较快捷的检测方法!
{
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];
}
}希望哪位同行能告诉我比较快捷的检测方法!
解决方案 »
- 关于ResumeLayout(false)报错
- 手上有个c/s项目用到“添加web引用”,这块我不太懂,请问“添加web引用”的作用?
- 大家帮帮忙吧
- c#开发播放器,想播放多种格式
- 在MDI中,将子窗体移出主窗体时,怎样才能使主窗体不产生滚动条?(急!在线等)
- 各位兄台:帮我看看这个WINDOWS服务怎么不循环。。
- 请教如何把用户在【SerialNumberTemplate】中输入的序列号带到安装后的程序中
- C#动态调用Delphi封装的窗口,提示“外部组件发生异常”
- 如何 取出网页上的超链接 不使用WebBrows控件????急急急
- winform做的程序可以在工业触摸屏电脑上使用吗?
- 字符所在字符串的位置
- VS2005中数据集配置提示不受支持(以前装的sql2005,现在装的是sql2008)
Socket s = new Socket(lep.Address.AddressFamily,
SocketType.Stream,
ProtocolType.Tcp);s.BeginConnect(lep, new AsyncCallback(ConnectCallback), s);
private static void ConnectCallback(IAsyncResult ar) {
try {
// Retrieve the socket from the state object.
Socket client = (Socket) ar.AsyncState; // Complete the connection.
client.EndConnect(ar); Console.WriteLine("Socket connected to {0}",
client.RemoteEndPoint.ToString()); // Signal that the connection has been made.
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
}以上摘自MSDN
IPEndPoint lep = new IPEndPoint(lipa.AddressList[0], 11000); Socket s = new Socket(lep.Address.AddressFamily,
SocketType.Stream,
ProtocolType.Tcp);
try{ while(true){
allDone.Reset(); Console.WriteLine("Establishing Connection");
s.BeginConnect(lep, new AsyncCallback(Async_Send_Receive.Connect_Callback), s); allDone.WaitOne();
}
}
catch (Exception e){
Console.WriteLine(e.ToString());
}
哈哈