0

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;
    }
  • Does this answer your question? [GetHostEntry is very slow](https://stackoverflow.com/questions/997046/gethostentry-is-very-slow) – Hominis_06 Jan 18 '23 at 19:03

0 Answers0