github.com/alandoherty/protosocket-net

A networking library for frame-based, performance focused asynchronous sockets on .NET

Open this visualization on its own page →

Contributors

1

Lines of Code

250

From

2018-11-01

To

2019-10-21

About alandoherty/protosocket-net

ProtoSocket is a high-performance networking library for .NET that specializes in frame-based asynchronous TCP socket communication. It supports .NET Standard 1.3 and above, making it compatible with .NET Framework 4.6, .NET Core, and modern versions of .NET. The library is built with performance in mind, leveraging System.IO.Pipelines—the same infrastructure used by ASP.NET Kestrel—for efficient I/O operations.

The library abstracts socket connections as "peers" that can function as either client or server connections, and provides multiple ways to receive packets including event handlers, async tasks, and observable subscriptions. It includes several advanced features such as request-response correlation for protocols that follow a request-reply pattern, passive and active protocol modes for different communication scenarios, SSL/TLS upgrade capabilities, connection filtering, and frame pooling for resource optimization. Developers implement custom protocol handling by creating an IProtocolCoder that processes incoming data using PipeReader.

ProtoSocket comes with practical examples including a basic Minecraft Classic server implementation, a binary chat application, and an SSL-secured chat application. The library is battle-tested for production use and released under the permissive MIT license. It provides both active mode where the library continuously reads frames, and passive mode for scenarios like protocol negotiation that require manual frame receiving. Additional utilities include built-in statistics tracking, connection accept modes for controlling client acceptance rates, and methods for queueing multiple frames to be sent as a batch.

Share this video