Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to get names of devices connected to my wireless network with below code:
C#
public string GetHostName(string ipAddress)
    {
        try
        {
            if (ipAddress != null)
            {
                IPHostEntry entry = Dns.GetHostEntry(ipAddress);
                if (entry != null)
                {
                    return entry.HostName;
                }
            }
        }
        catch (SocketException)
        {
            // MessageBox.Show(e.Message.ToString());
        }

        return null;
    }


But its not working for mobile devices it always return null in that case. However I checked in other utilities they are able to find the host name of these mobile devices. So how can I fix this in C#.Net?
Posted
Comments
Kornfeld Eliyahu Peter 7-Oct-15 8:14am    
Maybe the code runs on a computer not in the same network/segment as the wireless devices?
Member 12035728 7-Oct-15 8:19am    
No both are running on same network however it is able to find names for computer/PC but not mobile devices.
Kornfeld Eliyahu Peter 7-Oct-15 9:33am    
That's because WiFi connected devices not necessarily registered with your DNS server...
You should look for the WiFi access point and ask it...
Member 12035728 7-Oct-15 9:52am    
I don't think that is the case as these mobile devices names are available on router.
Kornfeld Eliyahu Peter 7-Oct-15 9:59am    
Which means that the router IS the access point, but not the DNS server...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900