How Socket.IO works
Let's walk through the code line by line. We imported the index.html.js template, which is a simple node module that exports string-based HTML data. Then, we created an HTTP server to handle the HTTP request and response via a web browser or any other client that renders an HTML view.
We created a real-time server by passing an instance of the server to the required Socket.IO library. Socket.IO is the crude library for our real-time app. It provides a wrapper to WebSocket. WebSocket is a protocol that performs a continuous communication handshake over TCP (transmission control protocol).
To put it into simple terms, once the client establishes the connection to the WebSocket server, the client doesn't have to make a specific ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access