VOOZH about

URL: https://www.nuget.org/packages/Kcp/

⇱ NuGet Gallery | Kcp 2.7.0




Kcp 2.7.0

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.
<PackageVersion Include="Kcp" Version="2.7.0" />
 
Directory.Packages.props
<PackageReference Include="Kcp" />
 
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 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.
#:package Kcp@2.7.0
 
 
#: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=Kcp&version=2.7.0
 
Install as a Cake Addin
#tool nuget:?package=Kcp&version=2.7.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

KCP C#版

开箱即用。也可以使用 Nuget 搜索。

👁 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 : IKcpSegment
    • KcpIO<Segment> : KcpCore<Segment>, IKcpIO where Segment : IKcpSegment
    • Kcp<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 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 is compatible.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 is compatible.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp1.0 netcoreapp1.0 was computed.  netcoreapp1.1 netcoreapp1.1 was computed.  netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard1.1 netstandard1.1 is compatible.  netstandard1.2 netstandard1.2 was computed.  netstandard1.3 netstandard1.3 was computed.  netstandard1.4 netstandard1.4 was computed.  netstandard1.5 netstandard1.5 was computed.  netstandard1.6 netstandard1.6 was computed.  netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 is compatible. 
.NET Framework net45 net45 was computed.  net451 net451 was computed.  net452 net452 was computed.  net46 net46 was computed.  net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen30 tizen30 was computed.  tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Universal Windows Platform uap uap was computed.  uap10.0 uap10.0 was computed. 
Windows Phone wpa81 wpa81 was computed. 
Windows Store netcore netcore was computed.  netcore45 netcore45 was computed.  netcore451 netcore451 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Kcp:

Package Downloads
EasySharpFrame

Simple Development!

Megumin.Remote

NetRemoteStandard的一个实现。

KCPNet

基于UDP以及开源项目Protobuf实现的帧同步网络库

Lakona.Rpc.Transport.Kcp

KCP client/server transport implementations for Lakona.Rpc.

GameFrameX.NetWork.Kcp

GameFrameX.NetWork.Kcp,GameFrameX 框架的 KCP 网络模块.框架文档主页: https://gameframex.doc.alianblank.com

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 5,682 11/16/2023
2.6.3 664 7/12/2023
2.6.2 377 6/16/2023
2.6.1 2,454 1/12/2023
2.6.0 1,487 10/29/2022
2.5.2 1,105 10/14/2022
2.5.1 544 10/10/2022
2.5.0 588 10/10/2022
2.4.1 571 10/7/2022
2.4.0 1,786 8/17/2022
2.3.0 9,457 9/16/2021
2.2.2 813 3/9/2021
2.2.1 607 2/4/2021
2.2.0 653 1/13/2021
2.1.0 933 12/2/2020
2.0.0 13,305 12/9/2019
1.3.2 995 4/5/2019
1.3.1 895 3/2/2019
1.3.0 867 3/1/2019
1.2.0 1,103 2/23/2019
Loading failed