1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/// <summary>
/// Resolves the host name from the given IP address.
/// </summary>
/// <param name="IPAddress">The ip address for getting the host name.</param>
/// <returns>The host name if exists else "no entry"</returns>
public static String GetHostNameByIp(String IPAddress)
{
System.Net.IPHostEntry Host = null;
try
{
System.Net.IPAddress IP;
if (System.Net.IPAddress.TryParse(IPAddress, out IP))
Host = System.Net.Dns.GetHostEntry(IP);
}
catch
{
}
return Host.IsNull() ? "No entry" : Host.HostName;
}
|