Skip to content

Instantly share code, notes, and snippets.

@bnoordhuis
Created December 11, 2012 12:09
Show Gist options
  • Save bnoordhuis/c9c968b1d8c7579bdff6 to your computer and use it in GitHub Desktop.
Save bnoordhuis/c9c968b1d8c7579bdff6 to your computer and use it in GitHub Desktop.
var net = require('net');
var N = 100;
var S = 1024 * 1024;
var server = net.createServer(function(conn) {
conn.pipe(conn);
conn.on('error', console.error);
});
server.listen(1234, function() {
net.createConnection(1234, function() { write(this) });
});
var n = 0;
function write(conn) {
console.log(n);
if (++n < N) {
conn.write(new Buffer(S), function() { write(conn) });
} else {
conn.destroy();
server.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment