From 0b4d688fc2c286422d989dc777926b6f908a00ce Mon Sep 17 00:00:00 2001 From: Michael Lidgren Date: Fri, 8 May 2015 19:07:42 +0200 Subject: [PATCH] GetBroadcastAddress problem fixed... again. --- Lidgren.Network/NetPeer.LatencySimulation.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Lidgren.Network/NetPeer.LatencySimulation.cs b/Lidgren.Network/NetPeer.LatencySimulation.cs index 00844c8..083e395 100644 --- a/Lidgren.Network/NetPeer.LatencySimulation.cs +++ b/Lidgren.Network/NetPeer.LatencySimulation.cs @@ -135,10 +135,13 @@ namespace Lidgren.Network internal bool ActuallySendPacket(byte[] data, int numBytes, NetEndPoint target, out bool connectionReset) { connectionReset = false; + IPAddress ba = default(IPAddress); try { + ba = NetUtility.GetCachedBroadcastAddress(); + // TODO: refactor this check outta here - if (target.Address == NetUtility.GetCachedBroadcastAddress()) + if (target.Address == ba) { // Some networks do not allow // a global broadcast so we use the BroadcastAddress from the configuration @@ -175,7 +178,7 @@ namespace Lidgren.Network } finally { - if (target.Address == IPAddress.Broadcast) + if (target.Address == ba) m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false); } return true; @@ -260,10 +263,12 @@ namespace Lidgren.Network m_statistics.PacketSent(numBytes, numMessages); #endif connectionReset = false; + IPAddress ba = default(IPAddress); try { // TODO: refactor this check outta here - if (target.Address == NetUtility.GetCachedBroadcastAddress()) + ba = NetUtility.GetCachedBroadcastAddress(); + if (target.Address == ba) m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); int bytesSent = m_socket.SendTo(m_sendBuffer, 0, numBytes, SocketFlags.None, target); @@ -292,7 +297,7 @@ namespace Lidgren.Network } finally { - if (target.Address == NetUtility.GetBroadcastAddress()) + if (target.Address == ba) m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false); } return;