WebSocket Proxy Server

TsgcWebSocketProxyServer — accepts WebSocket connections from clients (typically browsers) and forwards data to a plain TCP/IP server. The cleanest way to expose a legacy TCP backend to a modern browser front-end.

Forward WebSocket Traffic to Any TCP Backend

Bridges the WebSocket protocol gap so browsers can talk to plain TCP servers.

Browser-to-TCP Bridge

TsgcWebSocketProxyServer implements a WebSocket Server component that listens for client WebSocket connections and forwards data to a normal TCP/IP server. This is especially useful for browser connections because it lets a browser virtually connect to any TCP service that does not natively speak WebSocket.

Drop the proxy in front of legacy TCP services — SMTP relays, IRC servers, custom binary protocols, telnet endpoints, or proprietary trading feeds — and serve them to a JavaScript or browser-based client without rewriting the backend.

  • Accepts standard RFC 6455 WebSocket connections
  • Forwards traffic to any plain TCP/IP backend
  • Bidirectional streaming — browser sends and receives over WS
  • Standard sgcWebSockets server property surface (19 properties, 22 events)
  • Works with TLS / wss:// for secure browser connections
BROWSER PROXY SERVER TCP BACKEND ws:// tcp://

Two Sockets Per Client

Inbound WebSocket Connection

The proxy accepts the WebSocket handshake from the browser as any standard sgcWebSockets server would — HTTP upgrade, optional sub-protocols, optional TLS via wss:// for end-to-end encryption between browser and proxy.

Outbound TCP Connection

For each accepted client the proxy opens a corresponding TCP connection to the configured backend host and port. WebSocket frames received from the browser are unwrapped and written to the TCP socket; bytes received from the backend are wrapped into WebSocket frames and pushed to the browser.

Connection Lifetime

The proxy tracks the lifecycle of both sockets. Closing the WebSocket side closes the TCP side and vice versa. Use the standard sgcWebSockets server events (OnConnect / OnDisconnect / OnMessage / OnError) to log, authenticate or filter the bridged traffic.

Delphi Example

Bridge a browser WebSocket client to a TCP backend.

// Drop a TsgcWebSocketProxyServer on the form
// Listen for incoming WebSocket connections
sgcWebSocketProxyServer1.Host := '0.0.0.0';
sgcWebSocketProxyServer1.Port := 443;

// Optional: secure browser connections with TLS (wss://)
sgcWebSocketProxyServer1.SSL := True;
sgcWebSocketProxyServer1.SSLOptions.CertFile :=
  'server.crt';
sgcWebSocketProxyServer1.SSLOptions.KeyFile :=
  'server.key';

// Forward all bridged traffic to the TCP backend
sgcWebSocketProxyServer1.Proxy.Host := 'backend.internal';
sgcWebSocketProxyServer1.Proxy.Port := 25;

sgcWebSocketProxyServer1.Active := True;

// Browser side (JavaScript)
//   const ws = new WebSocket('wss://proxy.example.com');
//   ws.onopen   = () => ws.send('HELO browser');
//   ws.onmessage = ev => console.log(ev.data);

When to Reach for the Proxy Server

Browser-to-Legacy-TCP

Expose a legacy TCP service (binary protocol, custom server, MUD, IRC) to a modern browser without rewriting the backend.

Tunnel Through Firewalls

Some environments only allow ports 80 / 443. Front a backend TCP service with the proxy on 443/wss so corporate clients can reach it through restrictive egress.

Hosted Web Terminal

Browser-based terminal, remote shell or telnet client — the browser opens a WebSocket and the proxy bridges it to the underlying TCP server.

Add TLS to a Plain TCP Service

The TCP backend speaks plaintext. Front it with the proxy on wss:// so the browser sees TLS while the backend connection stays simple.

Bridge Browsers to Any TCP Backend

Download the free trial and turn any TCP service into a WebSocket-friendly endpoint.