软件编程
位置:首页>> 软件编程>> C#编程>> C# ping网络IP 实现网络状态检测的方法

C# ping网络IP 实现网络状态检测的方法

作者:jingxian  发布时间:2023-01-11 14:31:05 

标签:C#,ping

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; 



}
0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com