STTech.BytesIO
3.0.2-beta0324
dotnet add package STTech.BytesIO --version 3.0.2-beta0324
NuGet\Install-Package STTech.BytesIO -Version 3.0.2-beta0324
<PackageReference Include="STTech.BytesIO" Version="3.0.2-beta0324" />
<PackageVersion Include="STTech.BytesIO" Version="3.0.2-beta0324" />
<PackageReference Include="STTech.BytesIO" />
paket add STTech.BytesIO --version 3.0.2-beta0324
#r "nuget: STTech.BytesIO, 3.0.2-beta0324"
#:package STTech.BytesIO@3.0.2-beta0324
#addin nuget:?package=STTech.BytesIO&version=3.0.2-beta0324&prerelease
#tool nuget:?package=STTech.BytesIO&version=3.0.2-beta0324&prerelease
STTech.BytesIO
🚀 简介 (Introduction)
STTech.BytesIO 是一个高性能、轻量级的 .NET 字节流通信框架。它为开发者提供了统一的编程模型,用于处理 TCP、串口 (SerialPort) 和进程间通信 (IPC/NamedPipe) 等底层数据传输。
本框架深度集成了 System.IO.Pipelines,实现了高效的零拷贝数据处理模式,特别适用于工业自动化、物联网、高性能服务器等对通信稳定性与吞吐量有严苛要求的场景。
✨ 核心特性 (Key Features)
- 统一 API 架构: 无论是 TCP、串口还是命名管道,均使用一致的
Connect()/Send()/OnDataReceived模型,极大降低代码迁移成本。 - 卓越性能:
- ⚡ 零拷贝 (Zero-Copy): 基于
System.IO.Pipelines优化接收缓冲管理,减少 GC 压力。 - 🧵 原生异步: 全面采用
async/await异步编程模型,提升系统并发响应能力。
- ⚡ 零拷贝 (Zero-Copy): 基于
- 工业级稳健性:
- 🔄 自动重连: 内置指数退避或自定义间隔的自动重连机制。
- 💓 多级心跳: 支持双向心跳包发送与超时检测。
- 📦 协议解包 (Unpacker): 提供强大的封包/解包器,轻松解决粘包、半包问题。
- 高度可定制:
- 支持 SSL/TLS 加密通信。
- 支持自定义发送队列策略与优先级管理。
- 轻量化: 仅引用官方维护的基础库,拒绝臃肿。
🛠️ 安装 (Installation)
通过 NuGet 包管理器安装:
dotnet add package STTech.BytesIO
📖 快速上手 (Quick Start)
1. TCP 客户端 (TCP Client)
var client = new TcpClient { Host = "127.0.0.1", Port = 8080 };
// 订阅接收数据事件
client.OnDataReceived += (s, e) => {
Console.WriteLine($"收到数据: {BitConverter.ToString(e.Data)}");
};
// 建立连接
var result = await client.ConnectAsync();
if (result.IsSuccess) {
// 发送数据
await client.SendAsync(new byte[] { 0x01, 0x02, 0x03 });
}
2. 串口客户端 (Serial Client)
var client = new SerialClient { PortName = "COM1", BaudRate = 9600 };
await client.ConnectAsync();
await client.SendAsync(Encoding.UTF8.GetBytes("Hello Device"));
3. IPC 命名管道 (IPC Client)
var client = new IpcClient { PipeName = "MyTestPipe" };
await client.ConnectAsync();
🏗️ 架构概览 (Architecture)
graph TD
A[User Code] --> B[STTech.BytesIO.Core]
B --> C[BytesClient / BytesServer]
C --> D[TcpClient / TcpServer]
C --> E[SerialClient]
C --> F[IpcClient / IpcServer]
D --> G[System.Net.Sockets]
E --> H[System.IO.Ports]
F --> I[System.IO.Pipes]
G & H & I --> J[System.IO.Pipelines]
📦 关联项目 (Extensions)
- STTech.BytesIO.Modbus: 全方位的 Modbus RTU/TCP/ASCII 协议实现。
- STTech.BytesIO.SerialPortStream: 基于
SerialPortStream的增强型串口通信实现。
⚖️ 开源协议 (License)
本项目采用 Apache-2.0 协议开源。
🤝 贡献与支持 (Support)
- 提交问题: GitHub Issues
- 技术博客: CSDN 专栏
- 加入社区: 点击上方 Gitter 徽章进入实时讨论组。
Powered by KarFans Industrial Co., LTD.
| 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 was computed. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | 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 | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- STTech.CodePlus (>= 1.7.5.2)
- System.IO.Pipelines (>= 8.0.0)
- System.IO.Ports (>= 8.0.0)
-
.NETStandard 2.1
- STTech.CodePlus (>= 1.7.5.2)
- System.IO.Pipelines (>= 8.0.0)
- System.IO.Ports (>= 8.0.0)
-
net10.0
- STTech.CodePlus (>= 1.7.5.2)
- System.IO.Ports (>= 8.0.0)
-
net6.0
- STTech.CodePlus (>= 1.7.5.2)
- System.IO.Pipelines (>= 8.0.0)
- System.IO.Ports (>= 8.0.0)
-
net8.0
- STTech.CodePlus (>= 1.7.5.2)
- System.IO.Pipelines (>= 8.0.0)
- System.IO.Ports (>= 8.0.0)
-
net9.0
- STTech.CodePlus (>= 1.7.5.2)
- System.IO.Ports (>= 8.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on STTech.BytesIO:
| Package | Downloads |
|---|---|
|
STTech.BytesIO.Modbus
BytesIO Modbus 通信库,提供 Modbus-SerialPort / Modbus-TCP 通信客户端,支持 ASCII、RTU 协议及多种标准寄存器操作命令。 |
|
|
STTech.BytesIO.SerialPortStream
STTech.BytesIO 串口扩展库,基于 SerialPortStream 实现,提供比原生 SerialPort 更稳定、更高性能的串口通信支持。 |
|
|
STTech.BytesIO.Quic
这是一个基于 QUIC 协议的高性能 .NET 字节流通信库,作为 STTech.BytesIO 的扩展库,提供了统一的编程模型。 QUIC 协议原生支持加密(TLS 1.3)和多流并发,适用于高可靠性、低延迟的通信场景。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.2-beta0324 | 77 | 3/23/2026 |
v3.0 Major Update:
1. Architectural Consolidation: Merged Core, TCP, Serial, and IPC projects into a single unified library.
2. Lightweight Dependency: Migrated to official System.IO.Ports, reducing external package dependencies.
3. Performance Tuning: Deeply integrated System.IO.Pipelines for high-performance zero-copy data processing.
4. Simplified API: Provided a more intuitive and consistent interface for all transport types.