Skip to content

Instantly share code, notes, and snippets.

@othiym23
Last active December 23, 2015 23:29
Show Gist options
  • Save othiym23/6710287 to your computer and use it in GitHub Desktop.
Save othiym23/6710287 to your computer and use it in GitHub Desktop.
var net = require('net');
var domain = require('domain');
var expected = 0, caught = 0;
process.on('exit', function () {
assert(expected === caught);
console.log('ok expected', expected, 'caught', caught);
});
var d = domain.create();
d.on('error', function () { caught++; });
var server;
d.run(function() {
server = net.createServer(function () {
throw new Error("too lazy to actually implement");
});
});
expected++;
server.listen(8000);
var client = net.connect(
{port : 8000},
function () {
client.write('hi\r\n');
client.end();
}
);
client.on('end', function() { server.close(); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment