C# ping网络IP 实现网络状态检测的方法
public string GetHostNameByIp(string ip)
{
ip = ip.Trim();
if (ip == string.Empty)
return string.Empty;
try
{
// 是否 Ping 的通
if (this.Ping(ip))
{
System.Net.IPHostEntry host = System.Net.Dns.GetHostEntry(ip);
return host.HostName;
}
else
return string.Empty;
}
catch (Exception)
{
return string.Empty;
}
}
以上这篇C# ping网络IP 实现网络状态检测的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持phpstudy。
本文地址:https://www.stayed.cn/item/12246
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我