March 2018
Beginner to intermediate
344 pages
7h 7m
English
We can then create a new HTTP server using Express and listen for application connections with Socket.io by adding the following to server.js:
const app = require('express')();const http = require('http').Server(app);const io = require('socket.io')(http);const PORT = 3000;http.listen(PORT, () => console.log(`Listening on port: ${PORT}`));io.on('connection', socket => { console.log('A user connected.');});
If we then run node server.js from within our Terminal inside the server folder, we should see the message Listening on port: 3000. This means that once we implement Socket.io inside of our client application we'll be able to monitor whenever somebody connects to the application.
Read now
Unlock full access