.NET WebSocket Library | C# Client & Server Components | eSeGeCe

.NET WebSocket Library — Client and Server for C#

sgcWebSockets .NET is a complete WebSocket client and server library for C#: RFC 6455 framing, TLS, per-message-deflate compression, auto-reconnect, plus MQTT, AMQP, STOMP and WAMP sub-protocols and HTTP/2 in the same package. Install it from NuGet as esegece.sgcWebSockets or start with the free Community Edition.

One library from .NET Framework 2.0 to .NET 9

The same component suite as the Delphi product, ported to C# with the same class names and the same event-driven API.

A .NET WebSocket library should cover more than the wire protocol. System.Net.WebSockets gives you RFC 6455 framing; sgcWebSockets .NET adds what production applications need on top: a server that runs on TCP or HTTP.SYS (shared ports with IIS), a client with watchdog auto-reconnect and heartbeats, message queueing, proxy and authentication support, and the messaging sub-protocols (MQTT, AMQP, STOMP, WAMP) that would otherwise mean pulling in three more dependencies.

Target-framework coverage is unusually broad: .NET Framework 2.0–4.8.1, .NET Core 1.0–3.1, .NET 5/6/7/8/9 and .NET Standard 1.6/2.0, on Windows, Linux and macOS. Legacy WinForms applications and current ASP.NET Core services use the same package and the same code.

Client

TsgcWebSocketClient: RFC 6455 client with TLS, proxy, heartbeat and watchdog

Server

TsgcWebSocketHTTPServer: WebSocket + HTTP server over HTTP.SYS, shared ports, SSL/TLS

NuGet

esegece.sgcWebSockets: install from nuget.org for all .NET targets

Community Edition

Free: install esegece.sgcWebSockets.Community from NuGet, or download the zip for Windows, Linux 64-bit and macOS 64-bit (includes nag screen)

More than WebSocket framing

The parts you would otherwise build yourself, already in the box.

WebSocket client & server

RFC 6455 on both sides, with per-message-deflate compression (RFC 7692) and TLS up to 1.3 on the provided transport.

Auto-reconnect watchdog

The client's WatchDog and HeartBeat properties keep long-lived connections alive and re-establish them after network drops, with no extra code.

Messaging protocols

MQTT 3.1.1 / 5.0, AMQP 0.9.1 / 1.0, STOMP and WAMP clients built in. Talk to RabbitMQ, HiveMQ, Azure Service Bus or ActiveMQ from the same library.

HTTP/2

A native HTTP/2 client (RFC 9113) in the same package, for APIs like Apple Push Notifications that require it.

HTTP.SYS server

The server component binds through HTTP.SYS, so it can share port 80/443 with IIS and serve HTTP and WebSocket traffic from one process.

SignalR wire clients

TsgcWSAPI_SignalR and TsgcWSAPI_SignalRCore implement the SignalR client wire protocol, so an sgcWebSockets client can talk to an existing ASP.NET Core SignalR server.

AI/LLM API clients

OpenAI, Anthropic, Gemini, DeepSeek, Grok, Ollama, Mistral and MCP clients ship in the same suite, mirroring the Delphi AI family.

Authentication & security

Client and server expose Authentication, Proxy and TLSOptions / SSLOptions property groups; the server adds an OnAuthentication event for credential checks.

Same API as Delphi

Identical Tsgc* class names and events on both platforms, so teams that run Delphi and .NET side by side maintain one mental model.

A client and a server in C#

Set a few properties, hook the events, set Active. That is the whole pattern.

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");
using esegece.sgcWebSockets;

var server = new TsgcWebSocketHTTPServer();
server.Port = 80;

server.OnConnect    += (conn) => server.WriteData("welcome " + conn.IP);
server.OnMessage    += (conn, text) => server.WriteData(text);
server.OnDisconnect += (conn, code) => Console.WriteLine("#bye " + conn.IP);
server.OnAuthentication += (conn, user, pass, ref ok) =>
    { ok = (user == "admin" && pass == "s3cret"); };

server.Active = true;

From free Community to Enterprise

The free Community Edition is a full working build for Windows, Linux 64-bit and macOS 64-bit that shows a nag screen, the fastest way to evaluate the library in your own solution. The .NET editions are Community, Professional and Enterprise, and all three ship the same component set, including both the WebSocket client and the WebSocket server. The commercial editions differ in licensing rather than features: Professional removes the nag screen, adds the public C# interface source and grants a commercial redistribution licence, while Enterprise adds the full C# source code for rebuilding the assemblies plus priority support.

See the full .NET feature matrix for the per-edition breakdown, component by component.

More on sgcWebSockets .NET

.NET WebSocket libraries compared

A neutral, source-cited survey: sgcWebSockets .NET vs System.Net.WebSockets, SignalR, WebSocket-Sharp, Fleck and Watson.

.NET WebSocket client

Component reference for TsgcWebSocketClient on .NET: properties, methods, events.

.NET WebSocket server

Component reference for TsgcWebSocketHTTPServer on .NET: HTTP.SYS, shared ports, TLS.

.NET feature matrix

Every component and protocol, per edition and per target framework.

Blog: The NuGet package

Installing esegece.sgcWebSockets from nuget.org and getting a first connection running.

Download

Community Edition, compiled demos and the ASP.NET Core + React sample.

Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Add WebSockets to your .NET app today

Install esegece.sgcWebSockets from NuGet or grab the free Community Edition and run the demos.