take the first network ip. how can we be sure that this one is the right one?

This commit is contained in:
Alexander Eckart committed 2013-12-22 17:40:17 +01:00
1 parent c5c4fb856f
commit 18c1b3bd03
1 file changed
+2 -3
+2 -3
View File
@@ -206,13 +206,12 @@ namespace ServerLib
public static string GetLocalAddress() public static string GetLocalAddress()
{ {
IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName()); IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
string IPAddress = "";
foreach (IPAddress ip in ips) foreach (IPAddress ip in ips)
{ {
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
IPAddress = ip.ToString(); return ip.ToString();
} }
return IPAddress; return "";
} }
#region server control #region server control