You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
852 B

'use strict';
const common = require('../common');
const assert = require('assert');
const net = require('net');
const big = Buffer.alloc(1024 * 1024);
const server = net.createServer((socket) => {
socket.end(big);
server.close();
}).listen(0, () => {
let prev = 0;
function checkRaise(value) {
assert(value > prev);
prev = value;
}
const socket = net.connect(server.address().port, () => {
socket.on('data', (chunk) => {
checkRaise(socket.bytesRead);
});
socket.on('end', common.mustCall(() => {
assert.strictEqual(socket.bytesRead, prev);
assert.strictEqual(big.length, prev);
}));
socket.on('close', common.mustCall(() => {
assert(!socket._handle);
assert.strictEqual(socket.bytesRead, prev);
assert.strictEqual(big.length, prev);
}));
});
socket.end();
});