Skip to content

Instantly share code, notes, and snippets.

@claytonbez
Last active July 2, 2018 16:27
Show Gist options
  • Save claytonbez/943332068231e02293ae9d13fd5da32e to your computer and use it in GitHub Desktop.
Save claytonbez/943332068231e02293ae9d13fd5da32e to your computer and use it in GitHub Desktop.
Socket.io Server example
var express = require('express');
var app = express();
var http = require('http');
var server = http.createServer(app);
var io = require('socket.io')(server);
app.use("/", express.static(__dirname + "/public"));
app.get("/", function (req, res) {
res.sendFile(__dirname + '/index.html');
});
io.on('connection',function(socket){
console.log('Connected : ',socket.id);
socket.on('disconnect',function(){
console.log('Disconnected :',socket.id);
});
});
server.listen(80,function(){
console.log('ITNet Server Running on port 80');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment