Server code ( app.js )
Client Code ( index.html )
put these files in the same directory and install all dependencies.
run server !!
you can also download/fork the code from the link below.
https://github.com/sreekumar-kr/Expree3.0---Socket.IO
var express = require('express'); var app = express.createServer(); var socket = require('socket.io'); app.configure(function(){ app.use(express.static(__dirname + '/')); }); var server = app.listen(8081); var io = socket.listen(server); io.sockets.on('connection', function (socket) { console.log("connnect"); socket.on('disconnect', function (socket) { console.log("disconnect"); }); });
Client Code ( index.html )
<script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect('http://localhost:8081'); </script>
put these files in the same directory and install all dependencies.
run server !!
you can also download/fork the code from the link below.
https://github.com/sreekumar-kr/Expree3.0---Socket.IO