Featured

WebSockets for Delphi and CBuilder

WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection.

The WebSocket protocol enables interaction between a web browser (or other client application, like VCL Application) and a web server with lower overhead than half-duplex alternatives such as HTTP polling, facilitating real-time data transfer from and to the server. This is made possible by providing a standardized way for the server to send content to the client without being first requested by the client, and allowing messages to be passed back and forth while keeping the connection open. In this way, a two-way ongoing conversation can take place between the client and the server.

Unlike HTTP, WebSocket provides full-duplex communication.Additionally, WebSocket enables streams of messages on top of TCP. TCP alone deals with streams of bytes with no inherent concept of a message.

The WebSocket protocol specification defines ws (WebSocket) and wss (WebSocket Secure) as two new uniform resource identifier (URI) schemes that are used for unencrypted and encrypted connections, respectively.

sgcWebSockets library allow to build VCL WebSocket Servers and Clients.

sgcWebSockets

HandShake

To establish a WebSocket connection, the client sends a WebSocket handshake request, for which the server returns a WebSocket handshake response, as shown in the example below.

Client Request

GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Version: 13
Origin: http://example.com

Server Response

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=

sgcWebSockets 

sgcWebSockets is a complete package providing access to WebSockets protocol, allowing to create WebSockets Servers, Intraweb Clients or WebSocket Clients in VCL, Firemonkey, Linux and FreePascal applications.

  • Fully functional multithreaded WebSocket server according to RFC 6455.
  • Supports Firemonkey (Windows and MacOS).
  • Supports NEXTGEN Compiler (IOS and Android Support).
  • Supports LINUX Compiler.
  • Supports Lazarus / FreePascal.
  • Supports CBuilder.
  • Supports Chrome, Firefox, Safari, Opera and Internet Explorer (including iPhone, iPad and iPod)
  • Supports Microsoft HTTP Server API and IOCP for high-performance Windows Servers.
  • Multiple Threads Support. Indy Servers support IOCP or default Indy one thread per connection model.
  • Supports Message Compression using PerMessage_Deflate extension RFC 7692.
  • Supports Text and Binary Messages.
  • Supports Server and Client Authentication. OAuth2 is fully supported.
  • Server component providing WebSocket and HTTP connections through the same port.
  • Proxy Server component allowing to Web Browsers to connect to any TCP server.
  • WebBroker Server which supports DataSnap, HTTP and WebSocket connections using the same port.
  • Load Balancing Server.
  • Client WebSocket based on WinHTTP API.
  • Client WebSocket supports connections through Socket.IO Servers.
  • FallBack support through Adobe Flash for old Web Browsers like Internet Explorer from 6+.
  • Supports Server-Sent Events (Push Notifications) over HTTP Protocol.
  • WatchDog and HeartBeat built-in support.
  • Client WebSocket supports connections through HTTP Proxy Servers and SOCKS Proxy Servers.
  • Events Available: OnConnect, OnDisconnect, OnMessage, OnError, OnHandshake
  • Built-in sub-protocols: JSON-RPC 2.0, Dataset, Presence, WebRTC, MQTT (3.1.1 and 5.0) and WAMP (1.0 and 2.0)
  • Client Built-in API: Blockchain, Bitfinex, Pusher, SignalR Core, Huobi, CEX, Bitmex and Bittrex.
  • Support for JSON parsers: Delphi JSON and XSuperObject.
  • Built-in Javascript libraries to support browser clients.
  • Easy to setup
  • Javascript Events for full control
  • Async Events using Ajax
  • SSL/TLS Support for Server / Client Components (OpenSSL libraries required). OpenSSL 1.1.1 libraries are supported. Client supports SChannel for Windows

Supported IDE

  • Delphi 7 (* only supported if upgraded to Indy 10, Intraweb is not supported)
  • Delphi 2007
  • Delphi 2009
  • Delphi 2010
  • Delphi XE
  • Delphi XE2
  • Delphi XE3
  • Delphi XE4
  • Delphi XE5
  • Delphi XE6
  • Delphi XE7
  • Delphi XE8
  • Delphi 10 Seattle
  • Delphi 10.1 Berlin
  • Delphi 10.2 Tokyo
  • Delphi 10.3 Rio
  • CBuilder 2010
  • CBuilder XE
  • CBuilder XE2
  • CBuilder XE3
  • CBuilder XE4
  • CBuilder XE5
  • CBuilder XE6
  • CBuilder XE7
  • CBuilder XE8
  • CBuilder 10 Seattle
  • CBuilder 10.1 Berlin
  • CBuilder 10.2 Tokyo
  • CBuilder 10.3 Rio

Quickstart 

 Find below some articles to how use sgcWebSockets components

WebSockets Server

How build a WebSocket Delphi Server using sgcWebSockets library.

WebSockets Client

How build a WebSocket Delphi Client using sgcWebSockets library.

Online Documentation 

WebSockets .NET Server C#
Coturn for Windows

Related Posts