Skip to content

Instantly share code, notes, and snippets.

@brikis98
Last active February 15, 2019 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brikis98/7624718 to your computer and use it in GitHub Desktop.
Save brikis98/7624718 to your computer and use it in GitHub Desktop.
Echo server in socket.io
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
console.log("Someone just connected!");
// Echo back messages from the client
socket.on('message', function (message) {
console.log("Got message: " + message);
socket.emit('message', message);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment