You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-19 00:26:30 +09:00
Refactor NetPeer.Connect code to throw on non-resolvable address.
This commit is contained in:
@@ -244,12 +244,20 @@ namespace Lidgren.Network
|
|||||||
Recycle(msg);
|
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>
|
/// <summary>
|
||||||
/// Create a connection to a remote endpoint
|
/// Create a connection to a remote endpoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public NetConnection Connect(string host, int port)
|
public NetConnection Connect(string host, int port)
|
||||||
{
|
{
|
||||||
return Connect(new NetEndPoint(NetUtility.Resolve(host), port), null);
|
return Connect(GetNetEndPoint(host, port), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -257,7 +265,7 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public NetConnection Connect(string host, int port, NetOutgoingMessage hailMessage)
|
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>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user