ipv4 bugfix

This commit is contained in:
waltem01 2022-07-01 11:06:28 +02:00
parent 755f7a3639
commit 066422e796

View File

@ -29,7 +29,12 @@ public static class Connection {
try {
string hostName = Dns.GetHostName();
IPHostEntry entryList = Dns.GetHostEntry(hostName);
IPAddress ipv4Entry = entryList.AddressList[0];
IPAddress? ipv4Entry = null;
foreach (IPAddress entry in entryList.AddressList)
if (entry.AddressFamily == AddressFamily.InterNetwork) {
ipv4Entry = entry;
break;
}
ipAddress = ipv4Entry.ToString();
} catch (Exception) {}
}