Created
March 22, 2014 15:54
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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