Skip to content

Instantly share code, notes, and snippets.

@mAAdhaTTah
Last active August 29, 2015 14:23
Show Gist options
  • Save mAAdhaTTah/ab7dbca408e58146a7ca to your computer and use it in GitHub Desktop.
Save mAAdhaTTah/ab7dbca408e58146a7ca to your computer and use it in GitHub Desktop.
var http = require('http');
var _ = require('lodash');
// An HTTP server for an quick EventEmitter example. Works just like a socket.
var server = http.createServer(function(req, res) {
console.log('Reqest incoming...');
});
// This will not cause an error since partial is invoked after socket gets passed into the function.
server.on('connection', function(socket) {
setTimeout(_.partial(handleConnection, socket), 100);
});
function handleConnection(socket, time) {
console.log(socket, time);
}
server.listen(8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment