You've already forked lidgren-network-gen3
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:
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user