Creating a Node HTTP server with Socket.IO

In order to get Socket.IO running, we need to have at least one client and one server set up to talk to each other. In this recipe, we will set up a basic Node HTTP server with the built-in Node http module.

Getting ready

To get started with Socket.IO, you will need to install Node.js. This can be downloaded from https://nodejs.org/.There is a download link on the Node.js website, or you can get one of the binaries at https://nodejs.org/download/.

Once Node.js is installed, you will need to navigate to the directory where your project is located and create a new NPM package by entering npm init in your console.

Now, you will need to install Socket.IO. You can use NPM to install Socket.IO by entering npm install ...

Get Socket.IO 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.