Skip to content

Instantly share code, notes, and snippets.

@ericz
Created April 4, 2011 17:13
Show Gist options
  • Save ericz/901996 to your computer and use it in GitHub Desktop.
Save ericz/901996 to your computer and use it in GitHub Desktop.
example for socket.io issue `Double connections with blocking `alert` or `prompt` during io.connect()`
var http = require('http'),
io = require('socket.io'),
fs = require('fs'),
server = http.createServer(function(req, res){
// your normal server code
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(fs.readFileSync('test.html'));
});
server.listen(80);
// socket.io, I choose you
var socket = io.listen(server);
socket.on('connection', function(client){
console.log("Client connected!");
client.on('message', function(){});
client.on('disconnect', function(){});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment