Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Websockets Harness Real-Time Power In Your Delphi Apps

websockets hero image

Do you currently use websockets in your applications? Do you want to learn more about what websockets can do for your apps? Continue reading to learn everything you need to know about using websockets with Delphi, as well as a rundown of some of the available component sets that take the guesswork out of making the magic happen.

What are WebSockets?

A websocket implementation has two sides: the client side and the server side. A websocket server is, at its most basic, an application that listens for TCP traffic. Websocket clients are one or more applications or web pages that connect to the websocket server via a “handshake” request and, if successful, establish a continuous connection between the server and the client.

Are websockets just a special type of HTML?

The short answer to that question is no, websockets use the TCP communication protocol – not the much more heavyweight HTTP. The websockets server is not a web server, although it can be implemented on one. The websockets TCP traffic, the data sent back and forth between the client and server, is not the familiar “200 OK” and “HTTP/2.0 a bunch of HTML” type text data. The websockets protocol is very lightweight and as a result, very fast.

Websockets are also designed to be used in situations where there are prolonged and ‘constantly-on’ connections to the server by multiple clients. Compare that to HTML where the interaction is typically client makes a page request, the web server sends back its response and that’s end of interaction until the next web resource request. Websockets are more like a ‘push’ technology where the server can send updates without being asked. This push ability is more similar to the notifications on your mobile phone.

Are websockets secure?

The websocket protocol provides for both non-secure and secure connections. The secure protocol uses TLS/SSL.

Why would I want to use websockets in my app?

Websockets are really useful for applications which need to update small amounts of data frequently and on a schedule which is not predictable. You can use websockets to provide a highly efficient way of communicating that data without the overhead of things like REST which relies on HTML and therefore has all the added baggage of HTML request/response codes, headers and MIME types. Your applications cut out all that extra noise using websockets while providing a near real-time response without needing to implement things like the server or client polling for any requests or updates.

This makes your app super-responsive and lightweight.

What sort of applications can I write?

The most common example you see given for websockets is in real-time “chat” programs which emulate popular apps like Slack, Discourse and Messenger. There are a whole host of other uses too:

What websocket libraries are available for Delphi?

The “RAD” in RAD Studio Delphi is, of course, all about Rapid Application Development which means we use someone else’s hard work to make our lives easier. Luckily there is a solid stack of excellent Delphi websocket components available. This is a list of some of the more popular websocket component libraries available for Delphi. There are plenty of others so add a comment below if I’ve missed any you think should be on the list.

Commercial/paid websockets libraries for Delphi

IPWorks from /n Software have a specific Delphi websocket library.

A free trial of their library is available on GetIt https://getitnow.embarcadero.com/trial-ipworks-websockets-2020-c-builder-edition/

IPWorks is licensed per platform and includes free upgrades for a year.

Note that you would need a license for each platform if you buy it individually although /n Software do a “red carpet subscription” for just over twice the price of a single subscription and this gives you access to all editions and all platforms on multiple machines.

Devart’s Secure Bridge contains a websocket client for Delphi and it’s easy to use. They have a 60 day free trial after which the library requires a payment that comes with 1 year of technical support and updates. They do not have a websocket server component.

You can read more about Secure Bridge and the Delphi websocket client it contains here: https://www.devart.com/sbridge/delphi-websocket-client-component.html

ESEGECE Websockets is a really great library which provides components that implement both client and, in the Enterprise version, server-side websockets for Delphi.

The components work on all platforms including Windows, macOS, iOS and Android as well as Linux 64 bit.

There is a trial available after which you pay a single fee which includes one year of support.

You can get ESEGECE websockets from https://www.esegece.com/websocket

Web-based components for Delphi

If you are looking to write web applications with Delphi, TMS Software have websockets components available for use in TMS WEB Core applications. TMS WEB Core allows you to write fully interactive web applications using Delphi code.

There is a trial available of TMS WEB Core and you can then either buy the product individually or as part of their TMS All Access package which contains every component and library TMS sell.

You can read more about using websockets in your Delphi web applications here https://www.tmssoftware.com/site/blog.asp?post=460 and get more information about TMS WEB Core itself here: https://www.tmssoftware.com/site/tmswebcoreintro.asp

Free websockets libraries for Delphi

ICS Internet Component Suite is a free component suite from OverByte

ICS contains free Delphi websocket components which allow you to write apps that implement WebSocket clients and WebSocket servers. The ICS library is available only as source code and it works on all versions of Delphi from 7 right up to the latest versions. ICS also works cross-platform for macOS using Firemonkey.

The websockets are only a small part of ICS and it includes code for other protocols such as FTP, SMTP, HTTP and also supports SSL and TLS via OpenSSL. You can download ICS Internet Component Suite via GetIt: https://getitnow.embarcadero.com/ics-for-fmx-and-vcl/ or go directly to the OverByte download area to get the very latest version: http://wiki.overbyte.eu/wiki/index.php/ICS_Download

So, are you ready to use real-time streaming WebSockets in your Delphi programs? Try our IDE Software and make the most of it. Request a Free Trial here.

Exit mobile version