TouchSocket.SocketIo 4.2.9

Prefix Reserved
dotnet add package TouchSocket.SocketIo --version 4.2.9
                    
NuGet\Install-Package TouchSocket.SocketIo -Version 4.2.9
                    
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="TouchSocket.SocketIo" Version="4.2.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TouchSocket.SocketIo" Version="4.2.9" />
                    
Directory.Packages.props
<PackageReference Include="TouchSocket.SocketIo" />
                    
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 TouchSocket.SocketIo --version 4.2.9
                    
#r "nuget: TouchSocket.SocketIo, 4.2.9"
                    
#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 TouchSocket.SocketIo@4.2.9
                    
#: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=TouchSocket.SocketIo&version=4.2.9
                    
Install as a Cake Addin
#tool nuget:?package=TouchSocket.SocketIo&version=4.2.9
                    
Install as a Cake Tool

TouchSocket.SocketIo

TouchSocket 框架的 Socket.IO 协议组件,提供完整的 Socket.IO 客户端实现。

协议支持

  • 兼容 Socket.IO 3.x 和 4.x 协议
  • 支持 Engine.IO v3 和 v4 协议

传输方式

传输方式 说明
WebSocket 高性能双向通信
HTTP 长轮询 兼容性回退方案
自动升级 默认先通过 HTTP 长轮询握手,成功后自动升级为 WebSocket

核心特性

  • Emit/Ack 模型EmitAsync 发送事件,EmitWithAckAsync 发送并等待 Ack 响应
  • 命名空间 — 支持连接到指定 Namespace(如 /chat
  • 二进制附件 — 完整支持 _placeholder 占位符机制
  • 自定义 Query — 握手时可携带自定义查询参数
  • 插件扩展 — 通过 ISocketIoEventPlugin 拦截事件,ISocketIoHandshakedPlugin 监听握手
  • 可替换序列化器 — 默认内置 System.Text.Json,支持通过 ISocketIoSerializer 自定义

快速使用

var client = new SocketIoClient();
client.Setup(new TouchSocketConfig()
    .SetRemoteIPHost("http://localhost:3000")
    .Configure<SocketIoOption>(opt =>
    {
        opt.EIO = EngineIoVersion.V4;
        opt.Transport = EngineIoTransportType.WebSocket;
        opt.Namespace = "/chat";
    }));

await client.ConnectAsync();

// 发送事件
await client.EmitAsync("message", "hello");

// 发送并等待 Ack
var response = await client.EmitWithAckAsync("query", new object[] { "id" }, 5000);
var result = response.GetValue<string>(0);

支持的目标框架

  • net462
  • netstandard2.0
  • netstandard2.1
  • net6.0
  • net8.0
  • net10.0

文档

详细说明文档:https://touchsocket.net/

Product 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 was computed.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TouchSocket.SocketIo:

Package Downloads
TouchSocketPro.SocketIo

TouchSocketPro.SocketIo 是 TouchSocket 框架的企业版 Socket.IO 组件,在基础版客户端之上提供完整的 Socket.IO 服务端实现。 核心功能: - 完整的 Socket.IO 服务端,支持 WebSocket 和 HTTP 长轮询双模式 - 支持从 HTTP 轮询自动升级到 WebSocket - 兼容 Socket.IO 3.x 和 4.x 协议 - 会话管理(ISocketIoService),自动心跳检测与超时清理 - 灵活的服务端插件机制:事件处理(ISocketIoEventPlugin)、握手验证(ISocketIoHandshakedPlugin) - 依赖注入集成,支持 UseSocketIoServer() 一行配置启用 - 可自定义 URL 路径、Ping 间隔、超时时间、最大负载等参数 - 包含基础版全部客户端功能 说明文档:https://touchsocket.net/

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.2.9 79 5/10/2026