-
-
Save isaacs/4758403 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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