Working with Web Sockets

HTTP was designed to be half-duplex, which means it allows transmission of data in just one direction at a time. This makes it unsuitable for building real-time applications that need an open, persistent connection always. To overcome this limitation of HTTP, developers have created some workarounds or hacks. Some of these workarounds are polling, long polling, and streaming.

Web Sockets provide an asynchronous, bidirectional, full-duplex messaging implementation over a single TCP connection. In this recipe, you will learn how you can use Socket.IO and Express to create a simple echo application. The application simply reverses the message and echoes it back to the user browser.

Getting ready

To complete this recipe, you ...

Get OpenShift Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.