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

fixed performance snafu looking up broadcast address every packet send

This commit is contained in:
Michael Lidgren
2015-04-13 11:24:41 +02:00
parent 59995cc37b
commit 86a695cf2b
2 changed files with 9 additions and 1 deletions

View File

@@ -138,7 +138,7 @@ namespace Lidgren.Network
try
{
// TODO: refactor this check outta here
if (target.Address == NetUtility.GetBroadcastAddress())
if (target.Address == NetUtility.GetCachedBroadcastAddress())
{
// Some networks do not allow
// a global broadcast so we use the BroadcastAddress from the configuration

View File

@@ -75,6 +75,14 @@ namespace Lidgren.Network
return new NetEndPoint(adr, port);
}
private static IPAddress s_broadcastAddress;
public static IPAddress GetCachedBroadcastAddress()
{
if (s_broadcastAddress == null)
s_broadcastAddress = GetBroadcastAddress();
return s_broadcastAddress;
}
/// <summary>
/// Get IPv4 address from notation (xxx.xxx.xxx.xxx) or hostname (asynchronous version)
/// </summary>