From 3cc8b70009dfe7b95ac92edbe34868711bce6159 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Tue, 20 Oct 2015 22:48:40 +0200 Subject: [PATCH] Moved local ip to library --- ErgometerLibrary/NetHelper.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ErgometerLibrary/NetHelper.cs b/ErgometerLibrary/NetHelper.cs index 3a3faf9..6d65046 100644 --- a/ErgometerLibrary/NetHelper.cs +++ b/ErgometerLibrary/NetHelper.cs @@ -99,5 +99,20 @@ namespace ErgometerLibrary return ip; } + + public static IPAddress GetIP() + { + IPHostEntry host; + string localIP = "?"; + host = Dns.GetHostEntry(Dns.GetHostName()); + foreach (IPAddress ip in host.AddressList) + { + if (ip.AddressFamily == AddressFamily.InterNetwork) + { + localIP = ip.ToString(); + } + } + return GetIP(localIP); + } } }