GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - RevenantX/LiteNetLib: Lite reliable UDP library for Mono and .NET

BranchesTags
Open more actions menu

Latest commit

 

History

1,437 Commits
1,437 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
LibSample
LibSample
 
 
LiteNetLib.Tests
LiteNetLib.Tests
 
 
LiteNetLib.Trim.Dummy
LiteNetLib.Trim.Dummy
 
 
LiteNetLib
LiteNetLib
 
 
LiteNetLibSampleUnity
LiteNetLibSampleUnity
 
 
docfx_project
docfx_project
 
 
docs
docs
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE.txt
LICENSE.txt
 
 
LNL.png
LNL.png
 
 
LNL.svg
LNL.svg
 
 
LiteNetLib.sln
LiteNetLib.sln
 
 
README.md
README.md
 
 
appveyor.yml
appveyor.yml
 
 
update_docs.bat
update_docs.bat
 
 
update_docs.sh
update_docs.sh
 
 

Repository files navigation

LiteNetLib 2

Lite reliable UDP library for .NET Standard 2.1 (Mono, .NET)

Made in Ukraine

HighLevel API Part: LiteEntitySystem

Matrix chat: Matrix

Discord chat: Discord

OLD BRANCH (and examples) for 1.x

Little Game Example on Unity

Documentation

Build

NuGet NuGet NuGet NuGet

Release builds GitHub (pre-)release

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

  • "Buy Me A Coffee"

  • USDT TRC20: TE5eBgq8SyEeZFKtCgZG9GwL34sANmbc67

  • USDT BEP20/ERC20: 0x4c0D6DC76c6A6B354f5ec6c9e51893fFC6510d1E

  • Bitcoin: 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, channel, deliveryMethod) =>
{
    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();

Broadcast discovery

Set BroadcastReceiveEnabled on a manager that should receive broadcast packets. They are reported through OnNetworkReceiveUnconnected with UnconnectedMessageType.Broadcast. With multiple network interfaces, bind the manager to the local IPv4 address of the interface to use instead of calling Start(port):

using System.Net;
using LiteNetLib;

var listener = new EventBasedNetListener();
var manager = new NetManager(listener)
{
    BroadcastReceiveEnabled = true,
    IPv6Enabled = false
};

var localAddress = IPAddress.Parse("192.168.1.10"); // address assigned to the desired interface
manager.Start(localAddress, IPAddress.IPv6Any, 9050);

Use the same address-specific Start overload for a sender. To use multiple IPv4 interfaces, create a manager bound to each interface address.

About

Lite reliable UDP library for Mono and .NET

revenantx.github.io/LiteNetLib/index.html

Topics

cross-platformcsharpdot-netmononetworknetworkingreliable-packetsudpunity-3d

Resources

Readme
MIT license
Activity

Stars

3.6k stars

Watchers

145 watching

Forks

533 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.