110,552
社区成员
发帖
与我相关
我的任务
分享
public static bool testconn(string host)
{
try
{
host = "192.188.1.20";
Ping objPingsender = new Ping();
PingOptions objPingOptions = new PingOptions();
objPingOptions.DontFragment = true;
string data = "";
byte[] buffer = Encoding.UTF8.GetBytes(data);
int iTimeout = 120;
PingReply objPingreply = objPingsender.Send(host, iTimeout, buffer, objPingOptions);
string strInfo = objPingreply.Status.ToString();
if (strInfo == "Success")
{
return true;
}
else
{
return false;
}
}
catch(Exception)
{
return false;
}
}