.NET WebSocket 客户端

TsgcWebSocketClient for .NET — cross-platform WebSocket client supporting .NET Framework 2.0+, .NET Core, .NET 5–9, and .NET Standard. Runs on Windows, Linux, and macOS.

TsgcWebSocketClient (.NET)

C# / .NET port of TsgcWebSocketClient. Same property surface, same events, same class name — published under esegece.sgcWebSockets.

组件类

TsgcWebSocketClient

协议

WebSocket — RFC 6455

支持平台

.NET Framework 2.0–4.8, .NET Core 1.0–3.1, .NET 5–9, .NET Standard 1.6 / 2.0

版本

Standard / Professional / Enterprise

Drop the component, set a few properties, go

The same Host/Port/TLS/OnMessage surface as the Delphi component, idiomatic C#.

using esegece.sgcWebSockets;

var client = new TsgcWebSocketClient();
client.Host = "127.0.0.1";
client.Port = 80;
client.TLS  = true;
client.Options.Parameters = "/ws/";

client.OnConnect    += (conn) => Console.WriteLine("#connected: " + conn.IP);
client.OnDisconnect += (conn, code) => Console.WriteLine("#disconnected: " + code);
client.OnMessage    += (conn, text) => Console.WriteLine(text);
client.OnException  += (conn, ex) => Console.WriteLine("#exception: " + ex.Message);

client.Active = true;
client.WriteData("hello");

What's inside

23 published properties, 8 methods, 16 events — pulled from the component reference.

Connection

Published properties: Active, Host, Port.

Messaging

Published properties: QueueOptions.

Reliability

Published properties: HeartBeat, WatchDog.

Security

Published properties: Proxy, Authentication, TLSOptions.

Lifecycle

Events: OnConnect, OnDisconnect, OnError.

Data

Events: OnMessage, OnBinary, OnFragmented.

规范与参考

本组件实现协议的权威来源。

文档与演示

直接访问组件参考文档,获取即用型演示项目,并下载试用版。

在线帮助 — TsgcWebSocketClient 本组件的完整属性、方法和事件参考。
Demo Project — Demos\NET\WebSocket Client 即用型示例项目,随 sgcWebSockets 包提供——请在下方下载试用版。
技术文档 (PDF) 本组件的功能介绍、快速入门、Delphi、C++ Builder 和 .NET 代码示例及主要来源参考。
用户手册 (PDF) 涵盖库中所有组件的综合手册。

准备好开始了吗?

Download the .NET library and add WebSocket support to your C# application.