1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-17 15:46:33 +09:00

Fix for ResolveAsync throwing host not found exception

This commit is contained in:
lidgren
2011-10-03 05:17:53 +00:00
parent 5fc175677f
commit b2380e895d

View File

@@ -42,7 +42,14 @@ namespace Lidgren.Network
{ {
ResolveAsync(ipOrHost, delegate(IPAddress adr) ResolveAsync(ipOrHost, delegate(IPAddress adr)
{ {
callback(new IPEndPoint(adr, port)); if (adr == null)
{
callback(null);
}
else
{
callback(new IPEndPoint(adr, port));
}
}); });
} }
@@ -82,7 +89,23 @@ namespace Lidgren.Network
{ {
Dns.BeginGetHostEntry(ipOrHost, delegate(IAsyncResult result) Dns.BeginGetHostEntry(ipOrHost, delegate(IAsyncResult result)
{ {
entry = Dns.EndGetHostEntry(result); try
{
entry = Dns.EndGetHostEntry(result);
}
catch (SocketException ex)
{
if (ex.SocketErrorCode == SocketError.HostNotFound)
{
//LogWrite(string.Format(CultureInfo.InvariantCulture, "Failed to resolve host '{0}'.", ipOrHost));
callback(null);
return;
}
else
{
throw;
}
}
if (entry == null) if (entry == null)
{ {