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

Client WebSocket component — connects to any RFC 6455 WebSocket server and exchanges text and binary messages.

Klasa komponentu

TsgcWebSocketClient

Protokół

WebSocket — RFC 6455

Platformy

Windows, macOS, Linux, iOS, Android

Edycja

Standard / Professional / Enterprise

Drop the component, set a few properties, go

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");

Co jest w środku

23 published properties, 22 methods and 16 events — pulled straight from the component reference.

Connection control

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.

Keep-alive & reconnect

HeartBeat sends WebSocket ping frames on a timer; WatchDog automatically reconnects after an unexpected drop. OnBeforeHeartBeat and OnBeforeWatchDog let you customise each cycle.

TLS & proxy

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.

Messaging API

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.

Compression & throttling

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.

Diagnostics

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.

Specyfikacje i źródła

Autorytatywne źródła protokołów implementowanych przez ten komponent.

Dokumentacja i dema

Bezpośredni link do dokumentacji komponentu, gotowy do uruchomienia projekt demo i pobieranie wersji próbnej.

Pomoc online — TsgcWebSocketClient Pełna dokumentacja właściwości, metod i zdarzeń tego komponentu.
Demo Project — 01.WebSocket\01.Client Gotowy do uruchomienia projekt przykładowy. Dostarczany w pakiecie sgcWebSockets — pobierz wersję próbną poniżej.
Dokument techniczny (PDF) Features, quick start, code samples for Delphi, C++ Builder and .NET and primary-source references — this component only.
Podręcznik użytkownika (PDF) Kompleksowy podręcznik obejmujący każdy komponent biblioteki.

Ready to Get Started?

Pobierz bezpłatną wersję próbną i dodaj WebSocket client support do swojej aplikacji Delphi.