Skip to content

Instantly share code, notes, and snippets.

@isaacs isaacs/t.js
Created Feb 11, 2013

Embed
What would you like to do?
var tls = require('tls');
var path = require('path');
var fs = require('fs');
var cert_dir = 'test/fixtures/'
var PORT = 12346;
var options = { key: fs.readFileSync(cert_dir + '/test_key.pem'),
cert: fs.readFileSync(cert_dir + '/test_cert.pem'),
ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ] };
var server = tls.createServer(options, function(conn) {
conn.on('data', function(chunk) {
console.error('got chunk', chunk.length);
});
}).listen(PORT, function() {
var chunk = new Buffer(10);
chunk.fill('x');
var opt = {port:PORT, rejectUnauthorized: false };
var conn = tls.connect(opt, function() {
conn.on('drain', write);
write();
});
function write() {
console.error('start writing');
var i = 0;
while (false !== conn.write(chunk)) {
if (!(++i % 10000)) console.error(process.memoryUsage());
}
console.error('wait for drain');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.