xnetlib 1.0.1

dotnet add package xnetlib --version 1.0.1                
NuGet\Install-Package xnetlib -Version 1.0.1                
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="xnetlib" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add xnetlib --version 1.0.1                
#r "nuget: xnetlib, 1.0.1"                
#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 xnetlib as a Cake Addin
#addin nuget:?package=xnetlib&version=1.0.1

// Install xnetlib as a Cake Tool
#tool nuget:?package=xnetlib&version=1.0.1                

Xnet library

This is a useful library that helps you write server/client apps with very simple code.

How to install

  1. .NET CLI: dotnet add package xnetlib --version 1.0.0
  2. Package Manager: NuGet\Install-Package xnetlib -Version 1.0.0
  3. Package Reference: <PackageReference Include="xnetlib" Version="1.0.0" />

Simple Example

The code below is everything.

class MyPacketProvider :  Xnet.BasicPacketProvider<MyPacketProvider>
{
    /// <summary>
    /// Test packet.
    /// </summary>
    private class PACKET : Xnet.BasicPacket
    {
        public override Task ExecuteAsync(Xnet Connection)
        {
            Console.WriteLine(Connection.IsServerMode
                ? "SERVER RECEIVED: PACKET!" 
                : "CLIENT RECEIVED: PACKET!");

            return Connection.EmitAsync(this);
        }

        protected override void Decode(BinaryReader Reader)
        {
        }

        protected override void Encode(BinaryWriter Writer)
        {
        }
    }

    /// <inheritdoc/>
    protected override void MapTypes()
    {
        Map<PACKET>("test");
    }
}

// ---

var Options = new Xnet.ServerOptions();

Options.Endpoint = new IPEndPoint(IPAddress.Any, 7800);
Options.NetworkId = Guid.Empty;
Options.PacketProviders.Add(new Program());

var Services = new ServiceCollection();
using var Provider = Services.BuildServiceProvider();

await Xnet.Server(Provider, Options, Token);

Clients can be implemented in exactly the same way, except that they use Xnet.ClientOptions and Xnet.Client methods for options.

To go more deeper...

Read Xnet/Xnet.Options.cs, Xnet/Xnet.Server.cs and Xnet/Xnet.Client.cs files. The comments on the Options class and derived classes included in these files will help you understand.

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

NuGet packages (6)

Showing the top 5 NuGet packages that depend on xnetlib:

Package Downloads
xnetlib.streams

extendable network library

xnetlib.dsa

extendable network library

xnetlib.hosting

extendable network library

xnetlib.replika

extendable network library

xnetlib.buckets

extendable network library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 241 11/6/2023
1.0.0 266 10/19/2023