LiteNetLib 2.1.2
dotnet add package LiteNetLib --version 2.1.2
NuGet\Install-Package LiteNetLib -Version 2.1.2
<PackageReference Include="LiteNetLib" Version="2.1.2" />
<PackageVersion Include="LiteNetLib" Version="2.1.2" />
<PackageReference Include="LiteNetLib" />
paket add LiteNetLib --version 2.1.2
#r "nuget: LiteNetLib, 2.1.2"
#:package LiteNetLib@2.1.2
#addin nuget:?package=LiteNetLib&version=2.1.2
#tool nuget:?package=LiteNetLib&version=2.1.2
LiteNetLib 2
Lite reliable UDP library for .NET Standard 2.1 (Mono, .NET)
HighLevel API Part: LiteEntitySystem
Matrix chat: Matrix
OLD BRANCH (and examples) for 1.x
Build
NuGet

Release builds 
DLL build from master 
( Warning! Master branch can be unstable! )
Features
- Lightweight
- Small CPU and RAM usage
- Small packet size overhead ( 1 byte for unreliable, 4 bytes for reliable packets )
- Simple connection handling
- Peer to peer connections
- Helper classes for sending and reading messages
- Multiple data channels
- Different send mechanics
- Reliable with order
- Reliable without order
- Reliable sequenced (reliable only last packet)
- Ordered but unreliable with duplication prevention
- Simple UDP packets without order and reliability
- Fast packet serializer (Usage manual)
- Automatic small packets merging
- Automatic fragmentation of reliable packets
- Automatic MTU detection
- Optional CRC32C checksums
- UDP NAT hole punching
- NTP time requests
- Packet loss and latency simulation
- IPv6 support (using separate socket for performance)
- Connection statistics
- Multicasting (for discovering hosts in local network)
- Unity support
- Support for .NET8 optimized socket calls (much less gc)
- Supported platforms:
- Windows/Mac/Linux (.NET Framework, Mono, .NET Core, .NET Standard)
- Lumin OS (Magic Leap)
- MonoGame
- Godot
- Unity 2021.2 (Desktop platforms, Android, iOS, Switch)
Support developer
USDT TRC20:
TE5eBgq8SyEeZFKtCgZG9GwL34sANmbc67USDT BEP20/ERC20:
0x4c0D6DC76c6A6B354f5ec6c9e51893fFC6510d1EBitcoin:
bc1q269ecs8r5vnrum5qr5j98sdglhnxlulv0f6egd
Unity notes!!!
- Minimal supported Unity is 2021.2. For older Unity versions use 1.x library versions
- Always use library sources or OpenUPM package instead of precompiled DLL files ( because there are platform specific #ifdefs and workarounds for unity bugs )
Usage samples
Client
var listener = new EventBasedNetListener();
var client = new NetManager(listener);
client.Start();
client.Connect("localhost" /* host IP or name */, 9050 /* port */, "SomeConnectionKey" /* text key or NetDataWriter */);
listener.NetworkReceiveEvent += (fromPeer, dataReader, deliveryMethod, channel) =>
{
Console.WriteLine("We got: {0}", dataReader.GetString(100 /* max length of string */));
dataReader.Recycle();
};
while (!Console.KeyAvailable)
{
client.PollEvents();
Thread.Sleep(15);
}
client.Stop();
Server
var listener = new EventBasedNetListener();
var server = new NetManager(listener);
server.Start(9050 /* port */);
listener.ConnectionRequestEvent += request =>
{
if(server.ConnectedPeersCount < 10 /* max connections */)
request.AcceptIfKey("SomeConnectionKey");
else
request.Reject();
};
listener.PeerConnectedEvent += peer =>
{
Console.WriteLine("We got connection: {0}", peer); // Show peer IP
var writer = new NetDataWriter(); // Create writer class
writer.Put("Hello client!"); // Put some string
peer.Send(writer, DeliveryMethod.ReliableOrdered); // Send with reliability
};
while (!Console.KeyAvailable)
{
server.PollEvents();
Thread.Sleep(15);
}
server.Stop();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (34)
Showing the top 5 NuGet packages that depend on LiteNetLib:
| Package | Downloads |
|---|---|
|
EdenNetwork
Simple C# TCP/UDP socket server&client API for .NET & Unity |
|
|
Shaman.LiteNetLibAdapter
Package Description |
|
|
ShareLib.Network
网络基础帮助库 |
|
|
CitiesSkylinesMultiplayer.API
API for Multiplayer mod for Cities: Skylines |
|
|
FTServer
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.