Click or drag to resize

NetManager Class

More feature rich network manager with adjustable channels count
Inheritance Hierarchy
SystemObject
  LiteNetLibLiteNetManager
    LiteNetLibNetManager

Namespace: LiteNetLib
Assembly: NeoAxis.Core (in NeoAxis.Core.dll) Version: 2026.2.1.0 (2026.2.1.0)
Syntax
C#
public class NetManager : LiteNetManager, IEnumerable<NetPeer>, 
	IEnumerable

The NetManager type exposes the following members.

Constructors
 NameDescription
Public methodNetManagerInitializes a new instance of the NetManager class
Top
Properties
 NameDescription
Public propertyChannelsCount QoS channel count per message type (value must be between 1 and 64 channels)
Public propertyConnectedPeersCount Returns connected peers count
(Inherited from LiteNetManager)
Public propertyExtraPacketSizeForLayer Gets the additional size in bytes required by the active PacketLayerBase.
(Inherited from LiteNetManager)
Public propertyFirstPeer First peer. Useful for Client mode
Public propertyIsRunning Returns true if socket listening and update thread is running
(Inherited from LiteNetManager)
Public propertyLocalPort Local EndPoint (host and port)
(Inherited from LiteNetManager)
Public propertyNatPunchModule NatPunchModule for NAT hole punching operations
(Inherited from LiteNetManager)
Public propertyPoolCount
(Inherited from LiteNetManager)
Public propertyTtl
(Inherited from LiteNetManager)
Top
Methods
 NameDescription
Protected methodAddPeerToSet
(Inherited from LiteNetManager)
Public methodConnect(IPEndPoint, NetDataWriter) Connect to remote host
Public methodConnect(IPEndPoint, ReadOnlySpanByte) Connect to remote host
Public methodConnect(IPEndPoint, String) Connect to remote host
Public methodConnect(String, Int32, NetDataWriter) Connect to remote host
Public methodConnect(String, Int32, String) Connect to remote host
Protected methodContainsPeer
(Inherited from LiteNetManager)
Protected methodCreateConnectionRequest
(Overrides LiteNetManagerCreateConnectionRequest(IPEndPoint, NetConnectRequestPacket))
Protected methodCreateIncomingPeer
(Overrides LiteNetManagerCreateIncomingPeer(LiteConnectionRequest, Int32))
Public methodCreateNtpRequest(IPEndPoint) Create the requests for NTP server
Public methodCreateNtpRequest(String) Create the requests for NTP server (default port)
Public methodCreateNtpRequest(String, Int32) Create the requests for NTP server
Protected methodCreateOutgoingPeer
(Overrides LiteNetManagerCreateOutgoingPeer(IPEndPoint, Int32, Byte, ReadOnlySpanByte))
Protected methodCreateRejectPeer
(Overrides LiteNetManagerCreateRejectPeer(IPEndPoint, Int32))
Public methodDisconnectAll Disconnect all peers without any additional data
(Inherited from LiteNetManager)
Public methodDisconnectAll(Byte, Int32, Int32) Disconnect all peers with shutdown message
(Inherited from LiteNetManager)
Public methodDisconnectPeer(LiteNetPeer) Disconnect peer from server
(Inherited from LiteNetManager)
Public methodDisconnectPeer(LiteNetPeer, NetDataWriter) Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
(Inherited from LiteNetManager)
Public methodDisconnectPeer(LiteNetPeer, Byte) Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
(Inherited from LiteNetManager)
Public methodDisconnectPeer(LiteNetPeer, Byte, Int32, Int32) Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
(Inherited from LiteNetManager)
Public methodDisconnectPeerForce Immediately disconnect peer from server without additional data
(Inherited from LiteNetManager)
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodGetConnectedPeers(ListLiteNetPeer) Get copy of connected peers (without allocations)
(Inherited from LiteNetManager)
Public methodGetConnectedPeers(ListNetPeer) Get copy of connected peers (without allocations)
Public methodGetEnumerator 
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetPeerById Gets peer by peer id
(Inherited from LiteNetManager)
Public methodGetPeers(ListLiteNetPeer, ConnectionState) Get copy of peers (without allocations)
(Inherited from LiteNetManager)
Public methodGetPeers(ListNetPeer, ConnectionState) Get copy of peers (without allocations)
Public methodGetPeersCount Return peers count with connection state
(Inherited from LiteNetManager)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodManualUpdate Updates internal peer states, handles timeouts, processes NTP requests and sends buffered packets.
(Inherited from LiteNetManager)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodPollEvents Synchronizes arrived events from the background thread to your main-thread/INetEventListener
(Inherited from LiteNetManager)
Protected methodProcessEvent
(Overrides LiteNetManagerProcessEvent(NetEvent))
Protected methodProcessNtpRequests
(Overrides LiteNetManagerProcessNtpRequests(Single))
Protected methodRemovePeerFromSet
(Inherited from LiteNetManager)
Public methodSendBroadcast(Byte, Int32)
(Inherited from LiteNetManager)
Public methodSendBroadcast(NetDataWriter, Int32)
(Inherited from LiteNetManager)
Public methodSendBroadcast(Byte, Int32, Int32, Int32)
(Inherited from LiteNetManager)
Public methodSendToAll(Byte, DeliveryMethod) Send data to all connected peers (channel - 0)
(Inherited from LiteNetManager)
Public methodSendToAll(NetDataWriter, DeliveryMethod) Send data to all connected peers (channel - 0)
(Inherited from LiteNetManager)
Public methodSendToAll(ReadOnlySpanByte, DeliveryMethod) Send data to all connected peers (channel - 0)
(Inherited from LiteNetManager)
Public methodSendToAll(Byte, DeliveryMethod, LiteNetPeer) Send data to all connected peers (channel - 0)
(Inherited from LiteNetManager)
Public methodSendToAll(Byte, Byte, DeliveryMethod) Send data to all connected peers
Public methodSendToAll(NetDataWriter, DeliveryMethod, LiteNetPeer) Send data to all connected peers (channel - 0)
(Inherited from LiteNetManager)
Public methodSendToAll(NetDataWriter, Byte, DeliveryMethod) Send data to all connected peers
Public methodSendToAll(ReadOnlySpanByte, DeliveryMethod, LiteNetPeer) Send data to all connected peers (channel - 0)
(Inherited from LiteNetManager)
Public methodSendToAll(Byte, Int32, Int32, DeliveryMethod) Send data to all connected peers (channel - 0)
(Inherited from LiteNetManager)
Public methodSendToAll(Byte, Byte, DeliveryMethod, LiteNetPeer) Send data to all connected peers
Public methodSendToAll(NetDataWriter, Byte, DeliveryMethod, LiteNetPeer) Send data to all connected peers
Public methodSendToAll(Byte, Int32, Int32, DeliveryMethod, LiteNetPeer) Send data to all connected peers
(Inherited from LiteNetManager)
Public methodSendToAll(Byte, Int32, Int32, Byte, DeliveryMethod) Send data to all connected peers
Public methodSendToAll(Byte, Int32, Int32, Byte, DeliveryMethod, LiteNetPeer) Send data to all connected peers
Public methodSendUnconnectedMessage(Byte, IPEndPoint) Send message without connection
(Inherited from LiteNetManager)
Public methodSendUnconnectedMessage(NetDataWriter, IPEndPoint) Send message without connection
(Inherited from LiteNetManager)
Public methodSendUnconnectedMessage(ReadOnlySpanByte, IPEndPoint) Send message without connection
(Inherited from LiteNetManager)
Public methodSendUnconnectedMessage(NetDataWriter, String, Int32) Send message without connection. WARNING This method allocates a new IPEndPoint object and synchronously makes a DNS request. If you're calling this method every frame it will be much faster to just cache the IPEndPoint.
(Inherited from LiteNetManager)
Public methodSendUnconnectedMessage(Byte, Int32, Int32, IPEndPoint) Send message without connection
(Inherited from LiteNetManager)
Public methodStart Start logic thread and listening on available port
(Inherited from LiteNetManager)
Public methodStart(Int32) Start logic thread and listening on selected port
(Inherited from LiteNetManager)
Public methodStart(IPAddress, IPAddress, Int32) Start logic thread and listening on selected port
(Inherited from LiteNetManager)
Public methodStart(String, String, Int32) Start logic thread and listening on selected port
(Inherited from LiteNetManager)
Public methodStart(IPAddress, IPAddress, Int32, Boolean) Start logic thread and listening on selected port
(Inherited from LiteNetManager)
Public methodStartInManualMode(Int32) Start in manual mode and listening on selected port In this mode you should use ManualReceive (without PollEvents) for receive packets and ManualUpdate(...) for update and send packets This mode useful mostly for single-threaded servers
(Inherited from LiteNetManager)
Public methodStartInManualMode(IPAddress, IPAddress, Int32) Start in manual mode and listening on selected port In this mode you should use ManualReceive (without PollEvents) for receive packets and ManualUpdate(...) for update and send packets This mode useful mostly for single-threaded servers
(Inherited from LiteNetManager)
Public methodStartInManualMode(String, String, Int32) Start in manual mode and listening on selected port In this mode you should use ManualReceive (without PollEvents) for receive packets and ManualUpdate(...) for update and send packets This mode useful mostly for single-threaded servers
(Inherited from LiteNetManager)
Public methodStop Force closes connection and stop all threads.
(Inherited from LiteNetManager)
Public methodStop(Boolean) Force closes connection and stop all threads.
(Inherited from LiteNetManager)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Public methodTriggerUpdate Triggers update and send logic immediately (works asynchronously)
(Inherited from LiteNetManager)
Public methodTryGetPeerById Gets peer by peer id
(Inherited from LiteNetManager)
Top
Fields
 NameDescription
Protected field_headPeer
(Inherited from LiteNetManager)
Protected field_peersLock
(Inherited from LiteNetManager)
Protected field_udpSocketv4
(Inherited from LiteNetManager)
Public fieldAllowPeerAddressChange Allows peer change it's ip (lte to wifi, wifi to lte, etc). Use only on server
(Inherited from LiteNetManager)
Public fieldAutoRecycle Automatically recycle NetPacketReader after OnReceive event
(Inherited from LiteNetManager)
Public fieldBroadcastReceiveEnabled Allows receive broadcast packets
(Inherited from LiteNetManager)
Public fieldDisconnectOnUnreachable Disconnect peers if HostUnreachable or NetworkUnreachable spawned (old behaviour 0.9.x was true)
(Inherited from LiteNetManager)
Public fieldDisconnectTimeout If NetManager doesn't receive any packet from remote peer during this time (in milliseconds) then connection will be closed (including library internal keepalive packets)
(Inherited from LiteNetManager)
Public fieldDontRoute UDP Only Socket Option Normally IP sockets send packets of data through routers and gateways until they reach the final destination. If the DontRoute flag is set to True, then data will be delivered on the local subnet only.
(Inherited from LiteNetManager)
Public fieldEnableStatistics Toggles the collection of network statistics for the instance and all known peers
(Inherited from LiteNetManager)
Public fieldIPv6Enabled IPv6 support
(Inherited from LiteNetManager)
Public fieldMaxConnectAttempts Maximum connection attempts before client stops and call disconnect event.
(Inherited from LiteNetManager)
Public fieldMaxFragmentsCount Max fragmented packets size for reliable channels - that equals to data of size fragments count * (MTU-reliable header size)
(Inherited from LiteNetManager)
Public fieldMaxPacketPerManualReceive Maximum packets that can be received per one ManualReceive (PollEvents when started using StartInManualMode) 0 - infinite - but this can cause some big delays there is too many incoming packets
(Inherited from LiteNetManager)
Public fieldMtuDiscovery Automatically discovery mtu starting from. Use at own risk because some routers can break MTU detection and connection in result
(Inherited from LiteNetManager)
Public fieldMtuOverride Override MTU for all new peers registered in this NetManager, will ignores MTU Discovery!
(Inherited from LiteNetManager)
Public fieldNatPunchEnabled Enable nat punch messages
(Inherited from LiteNetManager)
Public fieldPacketPoolSize Maximum packet pool size (increase if you have tons of packets sending)
(Inherited from LiteNetManager)
Public fieldPingInterval Interval for latency detection and checking connection (in milliseconds)
(Inherited from LiteNetManager)
Public fieldReceivePollingTime Poll timeout in microseconds. Increasing can slightly increase performance in cost of slow NetManager.Stop(Socket.Close)
(Inherited from LiteNetManager)
Public fieldReconnectDelay Delay between initial connection attempts (in milliseconds)
(Inherited from LiteNetManager)
Public fieldReuseAddress Enables socket option "ReuseAddress" for specific purposes
(Inherited from LiteNetManager)
Public fieldSimulateLatency Simulate latency by holding packets for random time. (Works only in DEBUG builds or when SIMULATE_NETWORK is defined)
(Inherited from LiteNetManager)
Public fieldSimulatePacketLoss Simulate packet loss by dropping random amount of packets. (Works only in DEBUG builds or when SIMULATE_NETWORK is defined)
(Inherited from LiteNetManager)
Public fieldSimulationMaxLatency Maximum simulated round-trip latency (in milliseconds). Actual latency applied per direction is half of this value.
(Inherited from LiteNetManager)
Public fieldSimulationMinLatency Minimum simulated round-trip latency (in milliseconds). Actual latency applied per direction is half of this value.
(Inherited from LiteNetManager)
Public fieldSimulationPacketLossChance Chance of packet loss when simulation enabled. value in percents (1 - 100).
(Inherited from LiteNetManager)
Public fieldStatistics Statistics of all connections
(Inherited from LiteNetManager)
Public fieldUnconnectedMessagesEnabled Enable messages receiving without connection. (with SendUnconnectedMessage method)
(Inherited from LiteNetManager)
Public fieldUnsyncedDeliveryEvent If true - delivery event will be called from "receive" thread immediately otherwise on PollEvents call
(Inherited from LiteNetManager)
Public fieldUnsyncedEvents Events automatically will be called without PollEvents method from another thread
(Inherited from LiteNetManager)
Public fieldUnsyncedReceiveEvent If true - receive event will be called from "receive" thread immediately otherwise on PollEvents call
(Inherited from LiteNetManager)
Public fieldUpdateTime Library logic update and send period in milliseconds Lowest values in Windows doesn't change much because of Thread.Sleep precision To more frequent sends (or sends tied to your game logic) use TriggerUpdate
(Inherited from LiteNetManager)
Public fieldUseNativeSockets Experimental feature mostly for servers. Only for Windows/Linux use direct socket calls for send/receive to drastically increase speed and reduce GC pressure
(Inherited from LiteNetManager)
Top
Extension Methods
 NameDescription
Public Extension MethodForEachNetPeer
(Defined by RcCollectionExtensions)
Public Extension MethodMethodInvoke Calls the object method by name.
(Defined by ObjectEx)
Public Extension MethodPropertyGet Gets the value of the object property by name.
(Defined by ObjectEx)
Public Extension MethodPropertyGetT Gets the value of the object property by name.
(Defined by ObjectEx)
Public Extension MethodPropertySet Sets the value of the object property by name.
(Defined by ObjectEx)
Top
See Also