2020-03-25 22:03:42 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const net = require('net');
|
|
|
|
|
2020-04-28 23:50:49 +02:00
|
|
|
{
|
|
|
|
const server = net.createServer(common.mustCall((socket) => {
|
|
|
|
socket.end(Buffer.alloc(1024));
|
|
|
|
})).listen(0, common.mustCall(() => {
|
|
|
|
const socket = net.connect(server.address().port);
|
|
|
|
assert.strictEqual(socket.allowHalfOpen, false);
|
|
|
|
socket.resume();
|
|
|
|
socket.on('end', common.mustCall(() => {
|
|
|
|
process.nextTick(() => {
|
|
|
|
// Ensure socket is not destroyed straight away
|
|
|
|
// without proper shutdown.
|
|
|
|
assert(!socket.destroyed);
|
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
socket.on('finish', common.mustCall(() => {
|
2020-03-25 22:03:42 +01:00
|
|
|
assert(!socket.destroyed);
|
2020-04-28 23:50:49 +02:00
|
|
|
}));
|
|
|
|
socket.on('close', common.mustCall());
|
2020-03-25 22:03:42 +01:00
|
|
|
}));
|
2020-04-28 23:50:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const server = net.createServer(common.mustCall((socket) => {
|
|
|
|
socket.end(Buffer.alloc(1024));
|
|
|
|
})).listen(0, common.mustCall(() => {
|
|
|
|
const socket = net.connect(server.address().port);
|
|
|
|
assert.strictEqual(socket.allowHalfOpen, false);
|
|
|
|
socket.resume();
|
|
|
|
socket.on('end', common.mustCall(() => {
|
|
|
|
assert(!socket.destroyed);
|
|
|
|
}));
|
|
|
|
socket.end('asd');
|
|
|
|
socket.on('finish', common.mustCall(() => {
|
|
|
|
assert(!socket.destroyed);
|
|
|
|
}));
|
|
|
|
socket.on('close', common.mustCall(() => {
|
|
|
|
server.close();
|
|
|
|
}));
|
2020-03-25 22:03:42 +01:00
|
|
|
}));
|
2020-04-28 23:50:49 +02:00
|
|
|
}
|