WebSockets for Delphi / C#

Home

What are WebSockets

Home

Definition from Wikipedia

WebSocket is a web technology providing for bi-directional, full-duplex communications channels, over a single Transmission Control Protocol (TCP) socket. The WebSocket API is being standardized by the W3C, and the WebSocket protocol has been standardized by the IETF as RFC 6455.

WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application. The WebSocket protocol makes possible more interaction between a browser and a web site, facilitating live content and the creation of real-time games. This is made possible by providing a standardized way for the server to send content to the browser without being solicited by the client, and allowing for messages to be passed back and forth while keeping the connection open. In this way a two-way (bi-direction) ongoing conversation can take place between a browser and the server. A similar effect has been done in non-standardized ways using stop-gap technologies such as comet.

In addition, the communications are done over the regular TCP port number 80, which is of benefit for those environments which block non-standard Internet connections using a firewall. WebSocket protocol is currently supported in several browsers including Firefox and Google Chrome. WebSocket also requires web applications on the server to be able to support it.

More Information

Features Overview

Home

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

Authentication

sgcWebSockets implements 3 different types of WebSocket authentication:

Session

Client needs to do send an HTTP GET passing username and password, and if authenticated, server response a Session ID. With this Session ID, client open websocket connection passing as a parameter. You can use a normal HTTP request to get a session id using and passing user and password as parameters

http://host:port/sgc/req/auth/session/:user/:password

example: (user=admin, password=1234) --> http://localhost/sgc/req/auth/session/admin/1234

This returns a token that is used to connect to server using WebSocket connections:

ws://localhost/sgc/auth/session/:token

URL

Client open websocket connection passing username and password as a parameter.

ws://host:port/sgc/auth/url/username/password

example: (user=admin, password=1234) --> http://localhost/sgc/auth/url/admin/1234

Basic

implements Basic Access Authentication, only applies to VCL Websockets (Server and Client) and HTTP Requests (client webbrowsers don't implement this type of authentication). When a client tries to connect, it sends a header using AUTH BASIC specification.

Custom Objects

Every time a new WebSocket connection is established, sgcWebSockets creates a TsgcWSConnection class where you can access to some properties like identifier, bytes received/sent, client IP... and there is a property called Data where you can store objects in memory like database access, session objects...

Secure Connections

SSL support is based on Indy implementation, so you need to deploy openssl libraries in order to use this feature. In Compiled Demos file, there is a directory called Third-Parties/ openssl, where you can find the libraries need for every Delphi Version.

Compression

This is a feature that works very well when you need to send a lot of data, usually using a binary message, because it compresses WebSocket message using protocol "x-webkit-deflate-frame" which is supported by some browsers like Chrome.

Bindings

Usually Server have more than one IP, if you enable a WebSocket Server and set listening port to 80, when server starts, tries to listen port 80 of ALL IP, so if you have 3 IP, it will block port 80 of each IP's.

Bindings allows to define which exact IP and Port are used by the Server. Example, if you need to listen on port 80 for IP 127.0.0.1 (internal address) and 80.254.21.11 (public address).

Quality of Service (QoS)

SGC Default Protocol implements a QoS (Quality of Service) for message delivery, there are 3 different types:

Level 0: "At most once"

where messages are delivered according to the best efforts of the underlying TCP/IP network. Message loss or duplication can occur. This level could be used, for example, with ambient sensor data where it does not matter if an individual reading is lost as the next one will be published soon after.

Level 1: "At least once"

where messages are assured to arrive but duplicates may occur.

Level 2: "Exactly once"

where message are assured to arrive exactly once. This level could be used, for example, with billing systems where duplicate or lost messages could lead to incorrect charges being applied.

Queues

SGC Default Protocol implements Queues to add persistence to published messages (it's only available for Published messages)

Level 0

Messages are not queued on Server

Level 1

only last message is queued on Server, and is sent every time a client subscribes to a new channel or connects to server.

Level 2

All messages are queued on Server, and are sent every time a client subscribes to a new channel or connects to server.

Transactions

sgcWebSockets SGC Protocol supports transactional messaging, when a client commits a transaction, all messages sent by client are processed on server side. There are 3 methods called by client

StartTransaction

Creates a New Transaction on server side and all messages that are sent from client to server after this method, are queued on Server side, until client calls to Commit or Rollback

Commit

When a client calls to commit, all messages queued by server are processed.

RollBack

When a client calls to RollBack, all messages queued by server are deleted and not processed on server side.

Online DEMO

HTTP

TsgcWebSocketHTTPServer is a component that allows to handle WebSocket and HTTP connections using the SAME port. Is very useful when you need to setup a server where only HTTP port is enabled (usually 80 port). This component supports all TsgcWeBSocketServer features and allows to serve HTML pages.

You can serve HTML pages statically, using DocumentRoot property, example: if you save test.html in directory "C:\inetpub\wwwroot", and you set DocumentRoot to "C:\inetpub\wwwroot". If a client tries to access to test.html, it will be served automatically, example:

http://localhost/test.html

Or you can serve HTML or other resources dynamically by code, to do this, there is an event called OnCommandGet that is fired every time a client requests a new HTML page, image, javascript file...

Throttle

Bandwidth Throttling is supported by Server and Client components, if enabled, can limit the amount of bits per second sent/received by socket. Indy uses a blocking method, so if a client is limiting its reading, unread data will be inside client socket and server will be blocked from writing new data to client. As much slower is client reading data, much slower is server writing new data.

Proxy

Client WebSocket components support WebSocket connections through proxies

VCL Available Editions

Home

Delphi supported IDE:


Lazarus IDE:


Free Version

Compiled *.dcu files provided with free version are using default Indy and Intraweb version. If you have upgraded any of these packets, probably it won't work or you need to buy full source code version Buy Now


Library (Win32 / Win64)


HTML5 Builder IDE:

WebSockets Demo

Home

WebBrowser Demo

WebSocket messages are processed using javascript

Intraweb Demo

WebSocket messages are processed using Intraweb Async Events

Downloads

Home

Components and binary demos

Download Free Version of our WebSockets Components for Delphi. These components are completely Free including Commercial use. If you need source code, you can buy a one-time license fee and get all futures updates, Buy Now

WebSocket Implementation Reports

Home

Server / Client Report

The AutobahnTestsuite provides a fully automated test suite to verify client and server implementations of The WebSocket Protocol for specification conformance and implementation robustness.

We have tested sgcWebSockets Server and Client Components using this test suite and here you can view the results.

Order sgcWebSockets

Home

Ordering On-line

On-line orders are processed by ShareIt (USA/Europe). ShareIt accepts credit cards, fax and bank/wire transfers. ShareIt provides a printable invoice upon purchasing. ShareIt automatically calculates applicable VAT. 

After your order has been confirmed by ShareIt, eSeGeCe sends your source by email, usually within 48 hours. If you have not heard from us within one week, contact us.

IMPORTANT: SPAM / MAIL FILTERs should accept delivery email

Please, configure your mail filters to accept emails from ShareIt.com domain.

WARNING About Extended Download

Extended Download is a Share-it service where you can re-download products you have purchased, if you don't need you can delete this item before purchase.

WARNING when ordering in other currencies than USD

eSeGeCe products have USD prices. As a service to our customers, We allow you to pay in other currencies, for example EUR or GBP. Note: If you select any other currency than USD, ShareIt charges up to an 8% on top of the actual exchange rate! We recommend you purchase our products in USD to avoid this additional cost.

You can get more information about Orders here: More Information

PRODUCTS

Buy now your License to get sgcWebSockets source code.

When you buy a license, you'll get access to source code and ALL Future updates.