[Open Source] An Integrated Socket Network Communication Framework with a Comprehensive Set of Communication Modules
![[Open Source] An Integrated Socket Network Communication Framework with a Comprehensive Set of Communication Modules](https://yy123.ink/api/img/1782593614505-lvclv3.jpg)
1. Project Overview

TouchSocket is an integrated socket network communication framework for .NET (including C#, VB.Net, and F#). It includes a series of communication modules such as TCP, UDP, SSL, HTTP, WebSocket, RPC, JSON-RPC, WebAPI, and XML-RPC. It provides one-click solutions for TCP packet fragmentation and packet sticking issues, as well as UDP large-packet fragmentation and reassembly. Using protocol templates, you can quickly implement parsing for various data packet formats, including fixed headers, fixed lengths, and delimiter-based character ranges.
2. Open Source License
Licensed under Apache-2.0
3. Screenshots

4. Feature Overview
Feature Overview

TouchSocket Features at a Glance
Traditional IOCP vs. TouchSocket IOCP Mode
TouchSocket's IOCP implementation differs from traditional approaches. Taking Microsoft's official example as a reference, it allocates a block of memory using MemoryBuffer, divides it into equal sections, and assigns one section to each session for receiving data. After data is received, it copies the received data and processes the copied data. TouchSocket, however, retrieves an available memory block from the memory pool before each receive operation and uses it directly to receive data. Once the data arrives, the memory block is passed directly for processing, eliminating the need for copying. Although this is a relatively small design improvement, performance differs by a factor of 10 when transmitting 64 KB of data 100,000 times.
Data Processing Adapters
You have probably used other Socket products. TouchSocket also draws on the excellent design concepts of other products. The data processing adapter is one such example. However, unlike other implementations, TouchSocket's adapter functionality is more powerful, easier to use, and more flexible. It can not only parse data packets in advance but also parse data objects. Adapters can be replaced at any time, with changes taking effect immediately. For example, fixed-header processing can be used to preprocess data and resolve packet fragmentation and sticking issues. It can also directly parse HTTP and WebSocket data protocols.
Compatibility and Adaptability
TouchSocket provides multiple framework models and is fully compatible with all protocols based on TCP and UDP. For example, TcpService and TcpClient provide the same basic functionality as Socket, while improving framework robustness and concurrency. Connections and received data are exposed through events, making the framework more user-friendly.
5. Tech Stack
Supported Environments
-
.NET Framework 4.5 and later.
-
.NET 6.0 and later.
-
.NET Standard 2.0 and later.
Supported Frameworks
-
Console
-
WPF
-
Winform
-
Blazor Server
-
Xamarin
-
MAUI
-
Avalonia
-
Mono
-
Unity 3D (excluding WebGL)
-
Others (including all C#-based environments)