Ledon.Sockets.Client
0.0.1
dotnet add package Ledon.Sockets.Client --version 0.0.1
NuGet\Install-Package Ledon.Sockets.Client -Version 0.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="Ledon.Sockets.Client" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ledon.Sockets.Client" Version="0.0.1" />
<PackageReference Include="Ledon.Sockets.Client" />
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 Ledon.Sockets.Client --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Ledon.Sockets.Client, 0.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.
#:package Ledon.Sockets.Client@0.0.1
#: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=Ledon.Sockets.Client&version=0.0.1
#tool nuget:?package=Ledon.Sockets.Client&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Ledon.Sockets.Client
协议客户端:TCP/UDP 连接、断线自动重连、类型化收发。与 Ledon.Protocols(解析)、
Ledon.Sockets.Server(服务端)分开——按需引用。
builder.Services.AddLedonSocketClient(
o =>
{
o.Host = "127.0.0.1";
o.Port = 9000;
o.AutoReconnect = true; // 断线后按 ReconnectDelay 重连
o.ReconnectDelay = TimeSpan.FromSeconds(2);
},
new LengthPrefixedFrameCodec(),
new MyClientHandler());
客户端处理器
public class MyClientHandler : ClientHandlerBase
{
private readonly IProtocolClient _client;
public MyClientHandler(IProtocolClient client) => _client = client;
public override async Task OnConnectedAsync(CancellationToken ct)
{
// 登录握手:连上就发
await _client.SendPacketAsync(new LoginRequest { User = "alice" }, ct);
}
public override Task OnFrameAsync(ReadOnlyMemory<byte> frame, CancellationToken ct)
{
var reply = PacketSerializer<LoginReply>.Deserialize(frame.Span);
return Task.CompletedTask;
}
public override Task OnDisconnectedAsync(Exception? error, CancellationToken ct)
{
// 断线清理(重连由框架负责)
return Task.CompletedTask;
}
}
- 半包自动拼接;缓冲上限保护(默认 1MB);
SendPacketAsync(packet):包编码 + 帧编码一步完成;- TCP 客户端随宿主启动即连、停机即断;连接失败按间隔重试;
- 手动控制(不随宿主):直接
new TcpProtocolClient(...),自己管ConnectAsync/CloseAsync。
UDP 客户端
builder.Services.AddLedonSocketUdpClient(
o => { o.Host = "127.0.0.1"; o.Port = 9001; },
codec,
new MyClientHandler());
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Ledon.Module (>= 0.0.1)
- Ledon.Protocols (>= 0.0.1)
- Microsoft.Extensions.DependencyModel (>= 10.0.13)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Ledon.Sockets.Client:
| Package | Downloads |
|---|---|
|
Ledon.Sip.Client
Ledon SIP 客户端:基于 Socket 库的事务用户(重传/超时/响应匹配)。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1 | 45 | 10/28/2026 |