blob: aed14fe279eb5be5510267f82e517489f751bb85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
'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();
});
|