To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.
Create a folder, run npm init -f
on it and paste both server.js
and client.js
there (see files below). Needless to say, you must have Node.js installed on your system.
Install the required libraries:
npm install socket.io
npm install socket.io-client
Run the server:
node server
Open other terminal windows and spawn as many clients as you want by running:
node client