【发布时间】:2013-11-27 11:10:53
【问题描述】:
我尝试在reference 中像“CNLSH”先生一样使用 OpenNETCF 进行 ping,如果主机可用,它可以正常工作。如果不是,pingReply.Status 永远不会变为假,因为我会从 send-Method 获得异常(无法发送包)。没有 try/catch 是否有可能工作?
public static bool pingIP(String s_ip)
{
Ping ping = new Ping();
PingReply pingReply;
try
{
pingReply = ping.Send(s_ip,500);
}
catch (Exception)
{
System.Diagnostics.Debug.WriteLine("could not connect to " + s_ip);
return false;
}
if (pingReply.Status == IPStatus.Success)
return true;
else return false;
}
【问题讨论】:
标签: c# networking compact-framework opennetcf