Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
i want to know how can i get the users of the ips if any ip is free the it throws an error "No such host is known"
C#
string ip1 = "10.236.105.108";
           string ip2 = "10.236.105.208";
           string st = Convert.ToString(ip1.Substring(ip1.LastIndexOf('.') + 1));
           string lt = Convert.ToString(ip2.Substring(ip2.LastIndexOf('.') + 1));

           for (int i = Convert.ToInt32(st); i <= Convert.ToInt32(lt); i++)
           {
               string addr = ip1.Substring(0, ip1.LastIndexOf('.')) + '.' + i;
               IPHostEntry entry = Dns.GetHostEntry(addr);
           }
Posted

1 solution

That is correct, see the Remarks section at http://msdn.microsoft.com/en-us/library/ms143998(v=vs.110).aspx[^]. You just need to catch the exception and if it is an unknown address then ignore it and go on to the next one.
 
Share this answer
 
Comments
Maciej Los 6-May-14 7:31am    
+5!

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