mirror of https://github.com/lukechilds/node.git
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
828 B
37 lines
828 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(common.PORT, () => {
|
|
let prev = 0;
|
|
|
|
function checkRaise(value) {
|
|
assert(value > prev);
|
|
prev = value;
|
|
}
|
|
|
|
const socket = net.connect(common.PORT, () => {
|
|
socket.on('data', (chunk) => {
|
|
checkRaise(socket.bytesRead);
|
|
});
|
|
|
|
socket.on('end', common.mustCall(() => {
|
|
assert.equal(socket.bytesRead, prev);
|
|
assert.equal(big.length, prev);
|
|
}));
|
|
|
|
socket.on('close', common.mustCall(() => {
|
|
assert(!socket._handle);
|
|
assert.equal(socket.bytesRead, prev);
|
|
assert.equal(big.length, prev);
|
|
}));
|
|
});
|
|
socket.end();
|
|
});
|
|
|