Giter Site home page Giter Site logo

kcp-1's Introduction

KCP C#版。

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

Feature:

  • 异步API标准接口 IKcpIO.cs
    • ValueTask Recv(IBufferWriter writer, object option = null);
    • ValueTask Output(IBufferWriter 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>

测试:

[已修复]同一个进程两个Kcp echo测试,至少使用3个线程,否则可能死锁。

在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 删除了此函数(已内联)


赞助链接

支付宝

kcp-1's People

Contributors

kumokyaku avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.