ArkMirage.RakNet 0.1.0

dotnet add package ArkMirage.RakNet --version 0.1.0
                    
NuGet\Install-Package ArkMirage.RakNet -Version 0.1.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="ArkMirage.RakNet" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ArkMirage.RakNet" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ArkMirage.RakNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ArkMirage.RakNet --version 0.1.0
                    
#r "nuget: ArkMirage.RakNet, 0.1.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.
#:package ArkMirage.RakNet@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ArkMirage.RakNet&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ArkMirage.RakNet&version=0.1.0
                    
Install as a Cake Tool

RakNet

License: MIT .NET

Chinese

A pure C# implementation of the RakNet networking protocol for games and real-time applications. This library provides reliable message transport over UDP with multiple reliability levels, automatic retransmission, MTU discovery, and DoS protection.

This is a C# port of the original RakNet protocol.

Installation

Requirements

Add to your project

dotnet add reference path/to/RakNet.csproj

Or add a project reference:

<ItemGroup>
  <ProjectReference Include="path/to/RakNet.csproj" />
</ItemGroup>

Quick Start

Start a server

using RakNet;

var listener = new ListenConfig
{
    ErrorLog = msg => Console.WriteLine($"Error: {msg}")
}.Listen("0.0.0.0:19132");

Console.WriteLine($"Server listening on {listener.LocalEndPoint}");

while (true)
{
    var conn = listener.Accept();
    Console.WriteLine($"New connection from {conn.RemoteEndPoint}");

    new Thread(() =>
    {
        try
        {
            while (true)
            {
                byte[] data = conn.ReadPacket();
                conn.Write(data); // Echo back
            }
        }
        catch { }
    }) { IsBackground = true }.Start();
}

Connect as a client

using RakNet;

var dialer = new Dialer
{
    ErrorLog = msg => Console.WriteLine($"Error: {msg}")
};

var conn = dialer.Dial("127.0.0.1:19132");
Console.WriteLine($"Connected to {conn.RemoteEndPoint}");

conn.Write(System.Text.Encoding.UTF8.GetBytes("Hello, RakNet!"));

byte[] response = conn.ReadPacket();
Console.WriteLine($"Received: {System.Text.Encoding.UTF8.GetString(response)}");

conn.Close();

Unconnected ping (server discovery)

var dialer = new Dialer();
byte[] pongData = dialer.Ping("127.0.0.1:19132");
Console.WriteLine($"Server replied with {pongData.Length} bytes of pong data");

API Overview

Core Types

Type Description
Listener Server listener — binds a UDP port and accepts incoming connections
Dialer Client dialer — connects to a remote server
Conn Connection instance — provides Read() / Write() for data exchange
Packet Protocol-level packet encapsulation with reliability metadata and split info
Reliability Enum of reliability levels
IConnectionHandler Interface for handling internal RakNet packets

Reliability Levels

Level Value Description
Unreliable 0 No reliability, no ordering — fastest but may drop packets
UnreliableSequenced 1 Unreliable but sequenced — older packets are discarded
Reliable 2 Reliable but no ordering guarantee
ReliableOrdered 3 Reliable and ordered (default)
ReliableSequenced 4 Reliable but only the latest is kept

Configuration

public class Dialer
{
    public Action<string>? ErrorLog;        // Error log callback
    public int MaxTransientErrors;          // Maximum transient errors before abort
    public ushort MaxMTU;                   // Maximum MTU
    public IUpstreamDialer? UpstreamDialer; // Custom UDP socket factory
}

public class ListenConfig
{
    public Action<string>? ErrorLog;        // Error log callback
    public bool DisableCookies;             // Disable anti-spoofing cookies (not recommended)
    public ushort MaxMTU;                   // Maximum MTU
    public TimeSpan BlockDuration;          // IP block duration (default 10s)
}

License

This project is licensed under the MIT License.

Copyright (c) 2026 MCBE Community

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 126 8/25/2026