pingreply的send方法取不到IP地址

lg910046771 2018-06-28 08:40:00
我用PingReply对指定IP测试,结果objPingreply 拿不到地址,但是我把地址改成127.0.0.1就没问题 。
请各位大牛指教!

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;
}

}
...全文
383 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lg910046771 2018-06-28
  • 打赏
  • 举报
回复
刚发现图片插到代码里去了,我说咋没图
lg910046771 2018-06-28
  • 打赏
  • 举报
回复

110,552

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧