Skip to content

Instantly share code, notes, and snippets.

@purefan
Created March 22, 2014 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purefan/9709379 to your computer and use it in GitHub Desktop.
Save purefan/9709379 to your computer and use it in GitHub Desktop.
Quick reminder of how to make socket.io listen to an http server. Most examples online that I have found use Express which is ok, but for a small thing might be an overkill
// This is how we can make a socket.io server listen to an http connection
var http = require('http');
var socket = require('socket.io');
// Im not sure if the order is important
http.createServer(function(req,res){
// handle requests to your http server
});
// we tell socket.io to listen to the http node
socket.listen(http);
// and we tell http to listen to a port
http.listen(80);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment