Delphi WebSocket Client
TsgcWebSocketClient — a full-featured WebSocket client component for Delphi and C++ Builder with SSL/TLS, proxy support, message compression, and automatic reconnection.
TsgcWebSocketClient — a full-featured WebSocket client component for Delphi and C++ Builder with SSL/TLS, proxy support, message compression, and automatic reconnection.
Client WebSocket component — connects to any RFC 6455 WebSocket server and exchanges text and binary messages.
TsgcWebSocketClient
WebSocket — RFC 6455
Windows, macOS, Linux, iOS, Android
Standard / Professional / Enterprise
Set Host, Port and TLS, handle OnMessage, then activate the connection. The handshake, framing and ping/pong are managed for you.
uses
sgcWebSocket_Client, sgcWebSocket_Classes;
var
oClient: TsgcWebSocketClient;
begin
oClient := TsgcWebSocketClient.Create(nil);
oClient.Host := '127.0.0.1';
oClient.Port := 80;
oClient.TLS := True;
oClient.Options.Parameters := '/ws/';
oClient.OnConnect := OnConnect;
oClient.OnMessage := OnMessage;
oClient.OnDisconnect := OnDisconnect;
oClient.Active := True;
end;
procedure TForm1.OnMessage(Connection: TsgcWSConnection;
const Text: string);
begin
Memo1.Lines.Add(Text);
end;
// Send a text frame
oClient.WriteData('hello');
// uses: sgcWebSocket_Client, sgcWebSocket_Classes
TsgcWebSocketClient *oClient = new TsgcWebSocketClient(this);
oClient->Host = "127.0.0.1";
oClient->Port = 80;
oClient->TLS = true;
oClient->Options->Parameters = "/ws/";
oClient->OnConnect = OnConnect;
oClient->OnMessage = OnMessage;
oClient->OnDisconnect = OnDisconnect;
oClient->Active = true;
void __fastcall TForm1::OnMessage(TsgcWSConnection *Connection,
const UnicodeString Text)
{
Memo1->Lines->Add(Text);
}
// Send a text frame
oClient->WriteData("hello");
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.Active = true;
// Send a text frame
client.WriteData("hello");
23 published properties, 22 methods and 16 events — pulled straight from the component reference.
Host, Port, URL, TLS, IPVersion and Active open a synchronous or asynchronous connection. Connect/Disconnect block the caller, Start/Stop run on a worker thread.
HeartBeat sends WebSocket ping frames on a timer; WatchDog automatically reconnects after an unexpected drop. OnBeforeHeartBeat and OnBeforeWatchDog let you customise each cycle.
TLSOptions selects the IOHandler (OpenSSL or SChannel), TLS version (1.0–1.3) and ALPN; Proxy routes the handshake through HTTP or SOCKS; Authentication handles Basic / Bearer / custom schemes.
WriteData sends a text frame with optional fragmentation; WriteAndWaitData blocks until the peer answers; Ping sends a ping frame. OnMessage, OnBinary and OnFragmented deliver incoming data.
Extensions.PerMessage_Deflate negotiates RFC 7692 compression; Throttle caps bits-per-second in either direction; QueueOptions serialises Text / Binary / Ping writes on the connection thread.
LogFile dumps raw inbound and outbound traffic to disk; NotifyEvents selects how events are dispatched to the main thread; OnException, OnError and OnHandshake surface protocol-level details.
An alternative, Windows-only client that runs the WebSocket connection over the operating system's WinHTTP stack instead of Indy sockets — same WebSocket API, no third-party dependencies to deploy.
TsgcWSClient_WinHTTP — the same messaging API, events and connection control as TsgcWebSocketClient, so your code stays familiar.
Uses the native Windows WinHTTP API for the handshake and framing, so there are no extra socket libraries to ship with your application.
Secure connections are handled by Windows SChannel, so TLS works out of the box without bundling OpenSSL DLLs.
Honours the Windows system proxy configuration and integrates the Windows authentication schemes (Basic, NTLM, Negotiate).
Choose TsgcWSClient_WinHTTP when you want a pure Windows deployment that relies on the operating-system HTTP and TLS stack. For cross-platform targets (macOS, Linux, iOS, Android) use the standard TsgcWebSocketClient above.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — TsgcWebSocketClient Full property, method and event reference for this component. | Open | |
| Demo Project — 01.WebSocket\01.Client Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below. | Open | |
| Technical Document (PDF) Features, quick start, code samples for Delphi, C++ Builder and .NET and primary-source references — this component only. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |