take the first network ip. how can we be sure that this one is the right one?
This commit is contained in:
1 parent
deabae991a
commit
e2986c0f46
1 file changed
+2
-3
@@ -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
|
||||||
|
|||||||
Reference in new issue
Block a user