1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-15 22:56:30 +09:00

Refactor NetPeer.Connect code to throw on non-resolvable address.

This commit is contained in:
Marius Ungureanu
2015-09-05 10:56:17 +03:00
parent 2d1f9a4b91
commit 15a9a97ffb

View File

@@ -244,12 +244,20 @@ namespace Lidgren.Network
Recycle(msg);
}
static NetEndPoint GetNetEndPoint(string host, int port)
{
IPAddress address = NetUtility.Resolve(host);
if (address == null)
throw new NetException("Could not resolve host");
return new NetEndPoint(address, port);
}
/// <summary>
/// Create a connection to a remote endpoint
/// </summary>
public NetConnection Connect(string host, int port)
{
return Connect(new NetEndPoint(NetUtility.Resolve(host), port), null);
return Connect(GetNetEndPoint(host, port), null);
}
/// <summary>
@@ -257,7 +265,7 @@ namespace Lidgren.Network
/// </summary>
public NetConnection Connect(string host, int port, NetOutgoingMessage hailMessage)
{
return Connect(new NetEndPoint(NetUtility.Resolve(host), port), hailMessage);
return Connect(GetNetEndPoint(host, port), hailMessage);
}
/// <summary>