Skip to content

Instantly share code, notes, and snippets.

@tjfontaine
Created January 31, 2014 22:09
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 tjfontaine/8744274 to your computer and use it in GitHub Desktop.
Save tjfontaine/8744274 to your computer and use it in GitHub Desktop.
var util = require('util');
var assert = require('assert');
var net = require('net');
var SIZE = 2E6;
var BUF = new Buffer(SIZE);
var ERRS = 0;
var PORT = 4000;
BUF.fill(0x62);
var errs = [];
var srv = net.createServer(function onConnection(conn) {
conn.write(BUF);
conn.on('error', function (err) {
errs.push(err);
if (errs.length > 1 && errs[0] === errs[1]) {
assert(false, "We should not be emitting the same error twice");
srv.close();
}
});
}).listen(PORT, function () {
var client = net.connect({ port: PORT });
client.on('connect', function () {
client.resume();
client.destroy();
});
}).unref();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment