Click or drag to resize

LiteNetManager Class

Main class for all network operations. Can be used as client and/or server.
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 LiteNetManager : IEnumerable<LiteNetPeer>, 
	IEnumerable

The LiteNetManager type exposes the following members.

Constructors
 NameDescription
Public methodLiteNetManager NetManager constructor
Top
Properties
 NameDescription
Public propertyConnectedPeersCount Returns connected peers count
Public propertyExtraPacketSizeForLayer Gets the additional size in bytes required by the active PacketLayerBase.
Public propertyFirstPeer First peer. Useful for Client mode
Public propertyIsRunning Returns true if socket listening and update thread is running
Public propertyLocalPort Local EndPoint (host and port)
Public propertyNatPunchModule NatPunchModule for NAT hole punching operations
Public propertyPoolCount 
Public propertyTtl 
Top
Methods
 NameDescription
Protected methodAddPeerToSet 
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 
Protected methodCreateConnectionRequest 
Protected methodCreateIncomingPeer 
Protected methodCreateOutgoingPeer 
Protected methodCreateRejectPeer 
Public methodDisconnectAll Disconnect all peers without any additional data
Public methodDisconnectAll(Byte, Int32, Int32) Disconnect all peers with shutdown message
Public methodDisconnectPeer(LiteNetPeer) Disconnect peer from server
Public methodDisconnectPeer(LiteNetPeer, NetDataWriter) Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
Public methodDisconnectPeer(LiteNetPeer, Byte) Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
Public methodDisconnectPeer(LiteNetPeer, Byte, Int32, Int32) Disconnect peer from server and send additional data (Size must be less or equal MTU - 8)
Public methodDisconnectPeerForce Immediately disconnect peer from server without additional data
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 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
Public methodGetPeers Get copy of peers (without allocations)
Public methodGetPeersCount Return peers count with connection state
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.
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
Protected methodProcessEvent 
Protected methodProcessNtpRequests 
Protected methodRemovePeerFromSet 
Public methodSendBroadcast(Byte, Int32) 
Public methodSendBroadcast(NetDataWriter, Int32) 
Public methodSendBroadcast(Byte, Int32, Int32, Int32) 
Public methodSendToAll(Byte, DeliveryMethod) Send data to all connected peers (channel - 0)
Public methodSendToAll(NetDataWriter, DeliveryMethod) Send data to all connected peers (channel - 0)
Public methodSendToAll(ReadOnlySpanByte, DeliveryMethod) Send data to all connected peers (channel - 0)
Public methodSendToAll(Byte, DeliveryMethod, LiteNetPeer) Send data to all connected peers (channel - 0)
Public methodSendToAll(NetDataWriter, DeliveryMethod, LiteNetPeer) Send data to all connected peers (channel - 0)
Public methodSendToAll(ReadOnlySpanByte, DeliveryMethod, LiteNetPeer) Send data to all connected peers (channel - 0)
Public methodSendToAll(Byte, Int32, Int32, DeliveryMethod) Send data to all connected peers (channel - 0)
Public methodSendToAll(Byte, Int32, Int32, DeliveryMethod, LiteNetPeer) Send data to all connected peers
Public methodSendUnconnectedMessage(Byte, IPEndPoint) Send message without connection
Public methodSendUnconnectedMessage(NetDataWriter, IPEndPoint) Send message without connection
Public methodSendUnconnectedMessage(ReadOnlySpanByte, IPEndPoint) Send message without connection
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.
Public methodSendUnconnectedMessage(Byte, Int32, Int32, IPEndPoint) Send message without connection
Public methodStart Start logic thread and listening on available port
Public methodStart(Int32) Start logic thread and listening on selected port
Public methodStart(IPAddress, IPAddress, Int32) Start logic thread and listening on selected port
Public methodStart(String, String, Int32) Start logic thread and listening on selected port
Public methodStart(IPAddress, IPAddress, Int32, Boolean) Start logic thread and listening on selected port
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
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
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
Public methodStop Force closes connection and stop all threads.
Public methodStop(Boolean) Force closes connection and stop all threads.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Public methodTriggerUpdate Triggers update and send logic immediately (works asynchronously)
Public methodTryGetPeerById Gets peer by peer id
Top
Fields
 NameDescription
Protected field_headPeer 
Protected field_peersLock 
Protected field_udpSocketv4 
Public fieldAllowPeerAddressChange Allows peer change it's ip (lte to wifi, wifi to lte, etc). Use only on server
Public fieldAutoRecycle Automatically recycle NetPacketReader after OnReceive event
Public fieldBroadcastReceiveEnabled Allows receive broadcast packets
Public fieldDisconnectOnUnreachable Disconnect peers if HostUnreachable or NetworkUnreachable spawned (old behaviour 0.9.x was true)
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)
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.
Public fieldEnableStatistics Toggles the collection of network statistics for the instance and all known peers
Public fieldIPv6Enabled IPv6 support
Public fieldStatic memberIPv6Support 
Public fieldMaxConnectAttempts Maximum connection attempts before client stops and call disconnect event.
Public fieldMaxFragmentsCount Max fragmented packets size for reliable channels - that equals to data of size fragments count * (MTU-reliable header size)
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
Public fieldMtuDiscovery Automatically discovery mtu starting from. Use at own risk because some routers can break MTU detection and connection in result
Public fieldMtuOverride Override MTU for all new peers registered in this NetManager, will ignores MTU Discovery!
Public fieldNatPunchEnabled Enable nat punch messages
Public fieldPacketPoolSize Maximum packet pool size (increase if you have tons of packets sending)
Public fieldPingInterval Interval for latency detection and checking connection (in milliseconds)
Public fieldReceivePollingTime Poll timeout in microseconds. Increasing can slightly increase performance in cost of slow NetManager.Stop(Socket.Close)
Public fieldReconnectDelay Delay between initial connection attempts (in milliseconds)
Public fieldReuseAddress Enables socket option "ReuseAddress" for specific purposes
Public fieldSimulateLatency Simulate latency by holding packets for random time. (Works only in DEBUG builds or when SIMULATE_NETWORK is defined)
Public fieldSimulatePacketLoss Simulate packet loss by dropping random amount of packets. (Works only in DEBUG builds or when SIMULATE_NETWORK is defined)
Public fieldSimulationMaxLatency Maximum simulated round-trip latency (in milliseconds). Actual latency applied per direction is half of this value.
Public fieldSimulationMinLatency Minimum simulated round-trip latency (in milliseconds). Actual latency applied per direction is half of this value.
Public fieldSimulationPacketLossChance Chance of packet loss when simulation enabled. value in percents (1 - 100).
Public fieldStatistics Statistics of all connections
Public fieldUnconnectedMessagesEnabled Enable messages receiving without connection. (with SendUnconnectedMessage method)
Public fieldUnsyncedDeliveryEvent If true - delivery event will be called from "receive" thread immediately otherwise on PollEvents call
Public fieldUnsyncedEvents Events automatically will be called without PollEvents method from another thread
Public fieldUnsyncedReceiveEvent If true - receive event will be called from "receive" thread immediately otherwise on PollEvents call
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
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
Top
Extension Methods
 NameDescription
Public Extension MethodForEachLiteNetPeer
(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