I want to get the hostnames of a bunch of IPAdresses of my local network.
But Dns.GetHostEntry
is super slow.
It takes about 5 seconds per IP, even if no hostname is found.
Is there a faster way?
public static string GetHostName(string ipAddress)
{
try
{
IPHostEntry entry = Dns.GetHostEntry(ipAddress);
if (entry != null)
{
return entry.HostName;
}
}
catch (SocketException ex)
{
Console.WriteLine(ex);
return "Hostname not found";
}
return null;
}