Method of C ping Network IP Network State Detection
- 2021-11-02 02:04:19
- OfStack
C # ping Network IP Implementation of Network State Detection Method
public string GetHostNameByIp(string ip)
{
ip = ip.Trim();
if (ip == string.Empty)
return string.Empty;
try
{
// Whether or not Ping The communication of
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;
}
}