SuperSocketLite2 0.22.0
dotnet add package SuperSocketLite2 --version 0.22.0
NuGet\Install-Package SuperSocketLite2 -Version 0.22.0
<PackageReference Include="SuperSocketLite2" Version="0.22.0" />
<PackageVersion Include="SuperSocketLite2" Version="0.22.0" />
<PackageReference Include="SuperSocketLite2" />
paket add SuperSocketLite2 --version 0.22.0
#r "nuget: SuperSocketLite2, 0.22.0"
#:package SuperSocketLite2@0.22.0
#addin nuget:?package=SuperSocketLite2&version=0.22.0
#tool nuget:?package=SuperSocketLite2&version=0.22.0
SuperSocketLite2
Async TCP/UDP socket server library for .NET 10 (Windows/Linux), built for the kind of workload
that doesn't forgive sloppy I/O: real-time multiplayer game servers. A session-based, event-driven
framework on top of SocketAsyncEventArgs (IOCP) and System.IO.Pipelines, so you can focus on your
game protocol instead of reinventing connection management, buffer pooling, and backpressure handling.
This is a separate, from-scratch NuGet package — a different package ID from the older
SuperSocketLite package (still the pre-rewrite,
.NET 9 line). Installing this one does not affect existing SuperSocketLite users.
Install
dotnet add package SuperSocketLite2
A minimal echo server
public sealed class MyRequestInfo : IRequestInfo
{
public string Key => string.Empty;
public ReadOnlySequence<byte> Body { get; private set; }
public void Set(ReadOnlySequence<byte> body) => Body = body;
}
public sealed class MyReceiveFilter : FixedHeaderReceiveFilter<MyRequestInfo>
{
private readonly MyRequestInfo _reusable = new();
public MyReceiveFilter() : base(4) { }
protected override int GetBodyLengthFromHeader(ReadOnlySequence<byte> header)
{
Span<byte> buffer = stackalloc byte[4];
header.CopyTo(buffer);
return BinaryPrimitives.ReadInt32LittleEndian(buffer);
}
protected override MyRequestInfo ResolveRequestInfo(ReadOnlySequence<byte> header, ReadOnlySequence<byte> body)
{
_reusable.Set(body);
return _reusable;
}
}
public sealed class MySession : AppSession<MySession, MyRequestInfo> { }
public sealed class MyServer : AppServer<MySession, MyRequestInfo>
{
public MyServer() : base(new DefaultReceiveFilterFactory<MyReceiveFilter, MyRequestInfo>()) { }
}
var server = new MyServer();
server.NewRequestReceived += (session, request) =>
{
if (request.Body.IsSingleSegment)
session.SendCopied(request.Body.FirstSpan);
else
session.SendCopied(request.Body.ToArray());
};
server.Setup(new RootConfig(), new ServerConfig { Ip = "Any", Port = 2012, MaxConnectionNumber = 1000 },
logFactory: new ConsoleLogFactory());
server.Start();
Documentation
- README (full guide, quick start, configuration, observability)
- Getting Started — build, usage, must-knows
- Architecture guide and diagrams
- Tutorials / example servers
License
MIT
| 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. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
0.22.0 — The package now ships Roslyn analyzers (SSL001-SSL007) that catch the mistakes this library punishes only under load: a RequestInfo or its body escaping the request handler (stored in a field, captured in a lambda, or read after an await), a pooled buffer handed to the zero-copy Send, ReadOnlySequence read through First.Span, an ignored Setup/Start return value, and an unchecked GetAllSessions result. They turn on as soon as you reference the package; no configuration. Companion package SuperSocketLite2.Templates adds `dotnet new sslite2-server`. No API or behaviour changes to the library itself — upgrading from 0.21.1 may surface new warnings, and every one of them is worth reading. See Docs/agent/analyzers.md.
0.21.1 — First public release of SuperSocketLite2, a from-scratch .NET 10 / System.IO.Pipelines-based rewrite. This is a separate NuGet package from the older SuperSocketLite (still the pre-rewrite .NET 9 line); installing it does not affect existing SuperSocketLite users. Windows/Linux server-side use only.