Skip to content

Instantly share code, notes, and snippets.

@mafintosh
Created November 3, 2011 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mafintosh/1336685 to your computer and use it in GitHub Desktop.
Save mafintosh/1336685 to your computer and use it in GitHub Desktop.
var net = require('net');
net.createServer(function(socket) {
socket.setTimeout(10*1000, function() {
console.log('timeout!!');
socket.destroy();
});
setInterval(function() {
if (socket.writable) {
socket.write(Date.now()+'\n');
}
}, 1000);
}).listen(8888);
// and run: nc localhost 8888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment