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

Drop-in component for connecting to any RFC 6455 compliant WebSocket server.

Connect to Any WebSocket Server

TsgcWebSocketClient provides a complete WebSocket client implementation. Set the Host, Port, and TLS properties, handle the OnMessage event, and activate the connection. The component manages the handshake, frame encoding, ping/pong, and graceful close automatically. It supports text and binary messages, sub-protocols, custom headers, cookies, and HTTP proxy traversal.

  • SSL/TLS 1.2 and 1.3 with OpenSSL and SChannel
  • HTTP proxy and SOCKS proxy support
  • PerMessage-Deflate compression
  • WatchDog automatic reconnection
CLIENT SERVER wss:// TsgcWebSocketClient

Delphi Example

Connect to a WebSocket server, send and receive messages.

uses
  sgcWebSocket_Client, sgcWebSocket_Types;

var
  WSClient: TsgcWebSocketClient;

procedure TForm1.FormCreate(Sender: TObject);
begin
  WSClient := TsgcWebSocketClient.Create(nil);
  WSClient.Host := 'myserver.example.com';
  WSClient.Port := 443;
  WSClient.TLS := True;

  // Enable automatic reconnection
  WSClient.WatchDog.Enabled := True;
  WSClient.WatchDog.Interval := 10; // seconds

  // Enable compression
  WSClient.Extensions.PerMessageDeflate.Enabled := True;

  WSClient.OnConnect := OnConnect;
  WSClient.OnMessage := OnMessage;
  WSClient.OnDisconnect := OnDisconnect;
  WSClient.Active := True;
end;

procedure TForm1.OnMessage(Connection: TsgcWSConnection;
  const aText: string);
begin
  Memo1.Lines.Add('Received: ' + aText);
end;

procedure TForm1.ButtonSendClick(Sender: TObject);
begin
  WSClient.WriteData('Hello, WebSocket!');
end;

Ready to Get Started?

Download the free trial and add WebSocket client support to your Delphi application.