You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 07:36:32 +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
|
try
|
||||||
{
|
{
|
||||||
// TODO: refactor this check outta here
|
// TODO: refactor this check outta here
|
||||||
if (target.Address == NetUtility.GetBroadcastAddress())
|
if (target.Address == NetUtility.GetCachedBroadcastAddress())
|
||||||
{
|
{
|
||||||
// Some networks do not allow
|
// Some networks do not allow
|
||||||
// a global broadcast so we use the BroadcastAddress from the configuration
|
// a global broadcast so we use the BroadcastAddress from the configuration
|
||||||
|
|||||||
@@ -75,6 +75,14 @@ namespace Lidgren.Network
|
|||||||
return new NetEndPoint(adr, port);
|
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>
|
/// <summary>
|
||||||
/// Get IPv4 address from notation (xxx.xxx.xxx.xxx) or hostname (asynchronous version)
|
/// Get IPv4 address from notation (xxx.xxx.xxx.xxx) or hostname (asynchronous version)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user