OrangeCabinet 0.3.0

dotnet add package OrangeCabinet --version 0.3.0
                    
NuGet\Install-Package OrangeCabinet -Version 0.3.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="OrangeCabinet" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OrangeCabinet" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="OrangeCabinet" />
                    
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 OrangeCabinet --version 0.3.0
                    
#r "nuget: OrangeCabinet, 0.3.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.
#addin nuget:?package=OrangeCabinet&version=0.3.0
                    
Install OrangeCabinet as a Cake Addin
#tool nuget:?package=OrangeCabinet&version=0.3.0
                    
Install OrangeCabinet as a Cake Tool

OrangeCabinet - C# .NET async udp server & client

nuget .NET CI codecov License

feature

OrangeCabinet is 'Asynchronous Programming Model (APM)' socket wrapper library,
with 'Task-based Asynchronous Pattern (TAP)' at callback methods.
Otherwise, APM and TAP mixed.

  • Callback is below.
    • 'IncomingAsync' (received)
    • 'TimeoutAsync' (timeout)
    • 'ShutdownAsync' (shutdown)
  • Can store user value in remote.
  • Check timeout at regular intervals by last receive time.
  • Client bind too, not connect. So, previously known client port.

how to use

callback

public class Callback : OcCallback
{
    private const string Key = "inc";

    public override async Task IncomingAsync(OcRemote remote, byte[] message)
    {
        Console.WriteLine($"Received: {Encoding.UTF8.GetString(message)} ({remote})");

        var inc = remote.GetValue<int>(Key);
        inc++;
        remote.SetValue(Key, inc);

        await remote.SendAsync($"{inc}");
        if (inc > 10)
        {
            remote.ClearValue(Key);
            remote.Escape();
        }
    }

    public override Task TimeoutAsync(OcRemote remote)
    {
        Console.WriteLine($"Timeout: {remote}");
        return Task.CompletedTask;
    }

    public override Task ShutdownAsync(OcRemote remote)
    {
        Console.WriteLine($"Shutdown: {remote}");
        return Task.CompletedTask;
    }
}

for server (ip v4)

public static async Task Main(string[] args)
{
    var serverBinder = new OcBinder(new SampleCallback())
    {
        BindPort = 8710,
    };
    var server = new OcLocal(serverBinder);
    server.Start();
    await server.SendToAsync("0", new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8710));  // Send from server to some endpoint what you hope.
    server.WaitFor();
    // ...
    server.Shutdown();
}

for client (ip v4)

public static async Task Main(string[] args)
{
    using var clientBinder = new OcBinder(new Callback())
    {
        BindPort = 18710,
    };
    var client = new OcRemote(clientBinder, "127.0.0.1", 8710);
    for (int j = 0; j < 3; j++)
    {
        await client.SendAsync($"{j}");
    }
}

for server (ip v6)

public static async Task Main(string[] args)
{
    var serverBinder = new OcBinder(new SampleCallback())
    {
        SocketAddressFamily = OcSocketAddressFamily.Ipv6,
        BindPort = 8710,
    };
    var server = new OcLocal(serverBinder);
    server.Start();
    await server.SendToAsync("0", new IPEndPoint(IPAddress.Parse("::1"), 8710));  // Send from server to some endpoint what you hope.
    server.WaitFor();
    // ...
    server.Shutdown();
}

for client (ip v6)

public static async Task Main(string[] args)
{
    using var clientBinder = new OcBinder(new Callback())
    {
        SocketAddressFamily = OcSocketAddressFamily.Ipv6,
        BindPort = 18710,
    };
    var client = new OcRemote(clientBinder, "::1", 8710);
    for (int j = 0; j < 3; j++)
    {
        await client.SendAsync($"{j}");
    }
}
Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on OrangeCabinet:

Package Downloads
FluentNetting

Fluent forwarded server.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.0 146 5/7/2025
0.2.2 106 11/27/2024
0.2.1 107 11/22/2024
0.2.0 206 4/15/2024
0.0.9 272 12/8/2023
0.0.8 374 1/4/2023
0.0.7 316 1/2/2023
0.0.6 333 12/22/2022
0.0.5 413 12/13/2022
0.0.4 664 1/24/2022
0.0.3 651 1/13/2022
0.0.2 323 12/21/2021
0.0.1 324 12/10/2021