1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-18 08:06:33 +09:00

Use Dns.GetHostAddresses instead of Dns.GetHostEntry

This commit is contained in:
lidgren
2013-05-31 18:33:33 +00:00
parent 4dffa9dc9b
commit 7555b6958e

View File

@@ -169,20 +169,16 @@ namespace Lidgren.Network
} }
// ok must be a host name // ok must be a host name
IPHostEntry entry;
try try
{ {
entry = Dns.GetHostEntry(ipOrHost); var addresses = Dns.GetHostAddresses(ipOrHost);
if (entry == null) if (addresses == null)
return null; return null;
foreach (var address in addresses)
// check each entry for a valid IP address
foreach (IPAddress ipCurrent in entry.AddressList)
{ {
if (ipCurrent.AddressFamily == AddressFamily.InterNetwork) if (address.AddressFamily == AddressFamily.InterNetwork)
return ipCurrent; return address;
} }
return null; return null;
} }
catch (SocketException ex) catch (SocketException ex)