var express = require('express'); var app = express(); var server = app.listen(process.env.PORT); console.log("My socket server is running."); var socket = require('socket.io'); var io = socket(server); io.sockets.on('connection', function(socket){ console.log('new connection: ' + socket.id); console.log(socket.id); socket.on('msgFromWebsite', function(msg){ console.log('Received from website: ' + msg); console.log('Sending a thank you card...'); io.sockets.emit('msgFromServer', 'thanks for the message, website!'); //socket.broadcast.emit('msgFromServer', 'thanks for the message, website!'); }); });