const app = require('express')(); const server = require('http').createServer(app); const io = require('socket.io')(server); io.on('connection', socket => { console.log(`Client connected with id: ${socket.id}!`); // A client connects socket.on('data', (data) => { console.log('Received from client: ', data); // Received data from client }); }); server.listen(3000, () => { console.log('Server is listening on port 3000!'); // Started server });