WebSocket and HTTP Support

sgcWebSockets includes client and server-side implementations of the WebSocket protocol (RFC 6455). HTTP/s is also full supported.

SSL/TLS for Security

Your messages are secure using our SSL/TLS implementation. Widest compatibility via support for modern TLS 1.2, TLS 1.1 and TLS 1.0

Protocols and APIs

Several protocols are supported: MQTT, STOMP, WEBRTC, WAMP... Built-in protocols support Transactions, Datasets, QoS, big file transfers and more. APIs supported for third-parties like Pusher, Bitfinex...

Cross-platform

Share your code using our WebSockets library for your Delphi VCL, Firemonkey, Intraweb, Javascript and C# projects. Includes Server, Clients and serveral protocols for building and connecting to WebSocket applications.

MQTT

A lightweight messaging protocol for small sensors and mobile devices, optimized for high-latency or unreliable networks

WebRTC

Provides two application messaging patterns in one unified protocol: Remote Procedure Calls + Publish & Subscribe

STOMP

Simple Text Orientated Messaging Protocol

WAMP

Real-Time Communications (RTC) capabilities via JavaScript APIs.

SGC

Implemented using JSON-RPC 2.0 messages, provides following patterns: RPC, PubSub, Transactional Messages, Messages Acknowledgment and more.

FILES

implemented using binary messages, provides support for send files: packet size, authorization, QoS, message acknowledgment and more. Acknowledgment and more.

DATASET

Inherits from SGC Protocol and it's useful if you want to broadcast dataset changes over clients connected to this protocol.

Presence

Allows to know who is subscribed to a channel, example: chat rooms, collaborators on a document, people viewing the same web page, competitors in a game...

How Create VCL WebSocket Client

Example: open a websocket connection to echo.websocket.org

  1. Create a new VCL Forms Application 

  2. Drop a TsgcWebSocketClient in a Form and configure Host and Port Properties to connect to Server.

    sgcWebSocketClient1.Host := 'echo.websocket.org';

    sgcWebSocketClient1.Port := 80;

  3. Drop a TButton in a Form, Double Click and type this code:

   sgcWebSocketClient1.Active := True;

  4. Drop a TButton in a Form, Double Click and type this code:

   sgcWebSocketClient1.WriteData('Hello Server From VCL Client');

  5. Build Project and that's all, you have configured a basic WebSocket Client.

How Create VCL WebSocket Server

Example: create a server which listen on port 80

  1. Create a new VCL Forms Application 

  2. Drop a TsgcWebSocketServer in a Form and set listening port

      sgcWebsocketServer1.Port := 80;

  3. On Events Tab, Double click OnMessage Event, and type following code:

      ShowMessage('Message Received From Client: ' + Text);

  4. Drop a TButton in a Form, Double Click and type this code:

      sgcWebSocketServer1.Active := True;

   5. Build Project and that's all, you have configured a basic WebSocket Server.

How Create Linux WebSocket Server

Example: Simple Server listening on port 5000.

program sgcWebSockets_linux;

{$APPTYPE CONSOLE}

{$R *.res}

uses

  System.SysUtils, sgcWebSocket;

var

  oServer: TsgcWebSocketServer;

begin

  try

    oServer := TsgcWebSocketServer.Create(nil);

    oServer.Port := 5000;

    oServer.Active := True;

 

    while oServer.Active do

      Sleep(10);

  except

    on E: Exception do

      Writeln(E.ClassName, ': ', E.Message);

  end;

 

end.

WebBrowser Client

Example: open a websocket connection to 127.0.0.1:8000

  1. Create a new html file

  2. Open file with a text editor and copy following code:

<html>

<head>

<script type="text/javascript" src="http://127.0.0.1:8000/sgcWebSockets.js"></script>

</head>

<body>

<a href="javascript:var socket = new sgcWebSocket('ws://127.0.0.1:8000');">Open</a>

<a href="javascript:socket.send('Hello Server From Web Browser');">Send</a>

</body>

</html>

 3. Save file and you have configure a WebSocket WebBrowser client.

Delphi / C# WebSockets Components Trial

Download
Full Trial version, works for a time limited period and slow down connections.

CBuilder WebSockets Components Trial

Download
Full Trial version, works for a time limited period and slow down connections

Compiled WebSocket Demos

Download
Includes a set of compiled demos which shows the use of sgcWebSockets