LiteNetLib 1.2.0

dotnet add package LiteNetLib --version 1.2.0                
NuGet\Install-Package LiteNetLib -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LiteNetLib" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LiteNetLib --version 1.2.0                
#r "nuget: LiteNetLib, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LiteNetLib as a Cake Addin
#addin nuget:?package=LiteNetLib&version=1.2.0

// Install LiteNetLib as a Cake Tool
#tool nuget:?package=LiteNetLib&version=1.2.0                

LiteNetLib

Lite reliable UDP library for .NET Standard 2.0 (Mono, .NET Core, .NET Framework)

Made in Ukraine

HighLevel API Part: LiteEntitySystem

Discord chat: Discord

OLD BRANCH (and examples) for 0.9.x

Little Game Example on Unity

Documentation

Build

NuGet NuGet NuGet NuGet

Release builds GitHub (pre-)release

DLL build from master alternate text is missing from this package README image

( 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 (realiable 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 statisitcs
  • 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 2018.3 (Desktop platforms, Android, iOS, Switch)

Support developer

"Buy Me A Coffee"

Unity notes!!!

  • Minimal supported Unity is 2018.3. For older Unity versions use 0.9.x library versions
  • Always use library sources instead of precompiled DLL files ( because there are platform specific #ifdefs and workarounds for unity bugs )

Usage samples

Client

EventBasedNetListener listener = new EventBasedNetListener();
NetManager 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

EventBasedNetListener listener = new EventBasedNetListener();
NetManager 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
    NetDataWriter 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 Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 is compatible.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.7.1

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (24)

Showing the top 5 NuGet packages that depend on LiteNetLib:

Package Downloads
Tungsten

Tungsten is a C# library of classes to make application development easier

Shaman.LiteNetLibAdapter

Package Description

EdenNetwork

Simple C# TCP/UDP socket server&client API for .NET & Unity

NetworkOperation.LiteNet

Package Description

FTServer

Package Description

GitHub repositories (10)

Showing the top 5 popular GitHub repositories that depend on LiteNetLib:

Repository Stars
SubnauticaNitrox/Nitrox
An open-source, multiplayer modification for the game Subnautica.
OpenSAGE/OpenSAGE
OpenSAGE is a free, open source re-implementation of SAGE, the 3D real time strategy (RTS) engine used in Command & Conquer: Generals and other RTS titles from EA Pacific. Written in C#. Not affiliated with EA.
CitiesSkylinesMultiplayer/CSM
Source code for the Cities: Skylines Multiplayer mod (CSM)
Reloaded-Project/Reloaded-II
Universal .NET Core Powered Modding Framework for any Native Game X86, X64.
rwmt/Multiplayer
Zetrith's Multiplayer mod for RimWorld
Version Downloads Last updated
1.2.0 7,662 1/10/2024
1.1.0 11,786 4/24/2023
0.9.5.2 19,582 10/14/2021
0.8.3.1 34,128 3/13/2019