Revision: 36741
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 25, 2010 16:57 by falconzy
Initial Code
private bool CheckLocalAdress(string host) { try { // get host IP addresses IPAddress[] hostIPs = Dns.GetHostAddresses(host); // get local IP addresses IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); // test if any host IP equals to any local IP or to localhost foreach (IPAddress hostIP in hostIPs) { // is localhost if (IPAddress.IsLoopback(hostIP)) return true; // is local address foreach (IPAddress localIP in localIPs) { if (hostIP.Equals(localIP)) return true; } } return false; } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } }
Initial URL
Initial Description
Initial Title
Check Local IP Address
Initial Tags
Initial Language
C#