diff --git a/Lidgren.Network/NetPeer.LatencySimulation.cs b/Lidgren.Network/NetPeer.LatencySimulation.cs index d93fabe..cac8d50 100644 --- a/Lidgren.Network/NetPeer.LatencySimulation.cs +++ b/Lidgren.Network/NetPeer.LatencySimulation.cs @@ -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 diff --git a/Lidgren.Network/NetUtility.cs b/Lidgren.Network/NetUtility.cs index 055db86..a8bafd2 100644 --- a/Lidgren.Network/NetUtility.cs +++ b/Lidgren.Network/NetUtility.cs @@ -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; + } + /// /// Get IPv4 address from notation (xxx.xxx.xxx.xxx) or hostname (asynchronous version) ///