SocketSet 0.1.3
See the version list below for details.
dotnet add package SocketSet --version 0.1.3
NuGet\Install-Package SocketSet -Version 0.1.3
<PackageReference Include="SocketSet" Version="0.1.3" />
<PackageVersion Include="SocketSet" Version="0.1.3" />
<PackageReference Include="SocketSet" />
paket add SocketSet --version 0.1.3
#r "nuget: SocketSet, 0.1.3"
#:package SocketSet@0.1.3
#addin nuget:?package=SocketSet&version=0.1.3
#tool nuget:?package=SocketSet&version=0.1.3
SocketSet
High-performance, low-allocation socket hosting for .NET.
SocketSet is a sharded socket engine that puts your callbacks as close to the kernel's completion
notification as the platform allows. It picks the best available backend for the host and presents a
single API over all of them:
| Backend | Platform | Notes |
|---|---|---|
SocketSetFactory.IoUring |
Linux (5.x+, with the required features) | thread-per-shard, multishot accept, provided buffers, zero-copy echo |
SocketSetFactory.WindowsIocp |
Windows | raw Winsock + IOCP, bypassing managed sockets |
SocketSetFactory.WindowsRio |
Windows | Registered I/O; TCP-only, opt-in, latency-focused |
SocketSetFactory.Managed |
anywhere | portable SocketAsyncEventArgs fallback |
SocketSetFactory.Default probes the host and chooses for you (IOCP on Windows, io_uring on a
capable Linux kernel, otherwise the managed fallback), so the same binary runs everywhere and simply
goes faster where the platform lets it.
Supported frameworks: net10.0 and net472. (The native backends are .NET-only; .NET Framework
gets the managed fallback.)
Installation
dotnet add package SocketSet
Usage
Derive from SocketSet and override the callbacks you care about. Buffers are handed to you as
Span<byte> over memory the engine owns — you never allocate on the IO path, and you reply by
writing into the response buffer rather than by handing back an array.
using SocketSets;
using System.Net;
sealed class EchoServer(SocketSetOptions options) : SocketSet(options)
{
protected override void OnReceive(ref ReceiveContext ctx)
{
if (ctx.IsEof) return; // peer closed
// the payload is already sitting in RawBuffer; reply in-place by saying how much
// of that buffer to send back (mutate RawBuffer first if the response differs)
ctx.ResponseBytes = ctx.PayloadBytes;
}
}
using var server = new EchoServer(new SocketSetOptions { Shards = 4 });
server.Listen(new IPEndPoint(IPAddress.Any, 10000));
Console.ReadLine();
Outbound connections use the same type; OnConnect fires when the handshake completes, and
OnReceive handles the replies:
server.Connect(new IPEndPoint(IPAddress.Loopback, 10000));
To write from outside the IO callback (a background worker, a timer, a different connection's
callback), use the Connection handed to you — Send marshals onto the owning IO context and
serializes with the connection's other writes:
connection.Send(payload); // safe from any thread
Connection also implements IBufferWriter<byte>, so GetSpan/Advance/Flush works for
incremental composition.
Unix domain sockets are supported on all backends (UnixDomainSocketEndPoint, including the Linux
abstract namespace via a leading @), and an already-bound listener can be adopted by handle with
ListenHandle for socket-activation scenarios.
Configuration
SocketSetOptions controls sharding and the pre-allocated, pre-pinned buffer pools:
var options = new SocketSetOptions
{
Shards = Environment.ProcessorCount / 2,
SocketsPerShard = 4096,
PinWorkerThreads = true,
Factory = SocketSetFactory.Default,
};
Everything is sized up front: read buffers, write buffers, and connection slots are allocated per
shard when the set is constructed, so steady-state operation does not allocate. See the XML docs on
SocketSetOptions for the individual knobs and which backends honour them.
License
| Product | Versions 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. |
| .NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- System.Buffers (>= 4.6.1)
- System.Memory (>= 4.6.3)
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SocketSet:
| Package | Downloads |
|---|---|
|
SocketSet.AspNetCore
A Kestrel connection transport backed by SocketSet (io_uring / epoll / IOCP / RIO / managed), with optional transport-terminated TLS (OpenSSL/SChannel, plus kTLS on Linux). Add it with builder.WebHost.UseSocketSet(...). |
|
|
SocketSet.Garnet
Hosts Garnet on the SocketSet transport: an IGarnetServer whose connections are served by SocketSet's shard loops (io_uring / epoll / IOCP / RIO / managed) instead of the built-in SocketAsyncEventArgs layer. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.196-alpha | 95 | 8/3/2026 |
| 0.1.3 | 98 | 7/25/2026 |