Skip to content

Instantly share code, notes, and snippets.

@aviflax
Created June 17, 2010 23:47
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 aviflax/442972 to your computer and use it in GitHub Desktop.
Save aviflax/442972 to your computer and use it in GitHub Desktop.
// Listens on a port and just prints whatever it receives.
// Very useful for debugging
var net = require('net'),
sys = require('sys');
var server = net.createServer(function (stream) {
stream.setEncoding('utf8');
stream.addListener('connect', function () {
sys.puts('----CONNECT----');
});
stream.addListener('data', function (data) {
sys.puts(data);
});
stream.addListener('end', function () {
sys.puts('----DISCONNECT----');
stream.end();
});
});
// I was using port 5984, CouchDB's. Change to whatever you need.
server.listen(5984, 'localhost');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment