Kcp 2.7.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 1.1
This package targets .NET Standard 1.1. The package is compatible with this framework or higher.
dotnet add package Kcp --version 2.7.0
NuGet\Install-Package Kcp -Version 2.7.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="Kcp" Version="2.7.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kcp --version 2.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Kcp, 2.7.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.
// Install Kcp as a Cake Addin #addin nuget:?package=Kcp&version=2.7.0 // Install Kcp as a Cake Tool #tool nuget:?package=Kcp&version=2.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
KCP C#版
开箱即用。也可以使用 Nuget 搜索。
Feature:
- 异步API标准接口 IKcpIO.cs
- ValueTask Recv(IBufferWriter<byte> writer, object option = null);
- ValueTask Output(IBufferWriter<byte> writer, object option = null);
- 附带一个基本实现。KcpIO.cs
- kcpSegment泛型化,可由用户自定义高性能实现。
KcpCore<Segment>
where Segment : IKcpSegmentKcpIO<Segment>
:KcpCore<Segment>
, IKcpIO where Segment : IKcpSegmentKcp<Segment>
:KcpCore<Segment>
where Segment:IKcpSegment
链接:
c: skywind3000 KCP
go: xtaci kcp-go
说明:
- 内部使用了unsafe代码和非托管内存,不会对gc造成压力。
- 支持用户自定义内存管理方式,如果不想使用unsafe模式,可以使用内存池.
- 对于output回调和TryRecv函数。使用RentBuffer回调,从外部分配内存。请参考IMemoryOwner用法。
- 支持
Span<byte>
线程安全
简单的说:
不能在线程1调用Recv/Update时,线程2也在调用Recv/Update。函数内部使用大量共享数据结构,如果加锁严重影响性能。
可以在线程1调用Send/Input时,线程2也在调用Send/Input。函数内部有锁。
- 可以在任意多线程同时调用Send 和 Input。
多线程同时发送消息是安全的,可以放心的在异步函数中发送消息。 - 但
不可以
多个线程同时调用Recv 和 Update。
同名方法仅支持一个线程同时调用,否则会导致多线程错误。
测试:
在UnitTestProject1路径下执行 dotnet test 可进行多框架测试。(需要安装dotnetcoreSDK)
相对C版的一些变化:
差异变化 | C版 | C#版 |
---|---|---|
数据结构 | ||
acklist | 数组 | ConcurrentQueue |
snd_queue | 双向链表 | ConcurrentQueue |
snd_buf | 双向链表 | LinkedList |
rcv_buf | 双向链表 | LinkedList |
rcv_queue | 双向链表 | List |
-------------- | -------------- | -------------- |
回调函数 | 增加了RentBuffer回调,当KCP需要时可以从外部申请内存。 | |
多线程 | 增加了线程安全。 | |
流模式 | 由于数据结构变动,流模式不会填充当前未发送的最末的数据包。 | |
interval最小间隔 | 10ms | 0ms(在特殊形况下允许CPU满负荷运转) |
-------------- | -------------- | -------------- |
API变动 | ||
增加大小端编码设置。默认小端编码。 | ||
增加TryRecv函数,当可以Recv时只peeksize一次。 | ||
ikcp_ack_push | 删除了此函数(已内联) | |
ikcp_ack_get | 删除了此函数(已内联) |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. 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 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. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.1 is compatible. netstandard1.2 was computed. netstandard1.3 was computed. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 1.1
- NETStandard.Library (>= 1.6.1)
- System.Memory (>= 4.5.4)
- System.Threading.Tasks.Extensions (>= 4.5.4)
- System.ValueTuple (>= 4.5.0)
-
.NETStandard 2.0
- System.Memory (>= 4.5.4)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETStandard 2.1
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Kcp:
Package | Downloads |
---|---|
EasySharpFrame
Simple Development! |
|
Megumin.Remote
NetRemoteStandard的一个实现。 |
|
KCPNet
基于UDP以及开源项目Protobuf实现的帧同步网络库 |
|
YaoYuan.CoreServerSocket
Package Description |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Kcp:
Repository | Stars |
---|---|
KumoKyaku/Megumin.Net
应用程序和游戏网络模块解决方案
|
|
suxf/ECSharp
Easy .NET Develop Frame.
|
Version | Downloads | Last updated |
---|---|---|
2.7.0 | 1,663 | 11/16/2023 |
2.6.3 | 476 | 7/12/2023 |
2.6.2 | 223 | 6/16/2023 |
2.6.1 | 1,649 | 1/12/2023 |
2.6.0 | 1,232 | 10/29/2022 |
2.5.2 | 877 | 10/14/2022 |
2.5.1 | 363 | 10/10/2022 |
2.5.0 | 399 | 10/10/2022 |
2.4.1 | 386 | 10/7/2022 |
2.4.0 | 1,531 | 8/17/2022 |
2.3.0 | 8,719 | 9/16/2021 |
2.2.2 | 572 | 3/9/2021 |
2.2.1 | 387 | 2/4/2021 |
2.2.0 | 423 | 1/13/2021 |
2.1.0 | 666 | 12/2/2020 |
2.0.0 | 12,120 | 12/9/2019 |
1.3.2 | 734 | 4/5/2019 |
1.3.1 | 657 | 3/2/2019 |
1.3.0 | 614 | 3/1/2019 |
1.2.0 | 789 | 2/23/2019 |
1.1.0 | 601 | 2/21/2019 |
1.0.1 | 663 | 2/14/2019 |
1.0.0 | 655 | 2/13/2019 |