deno.land / std@0.166.0 / node / _tools / test / parallel / test-net-allow-half-open.js
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455// deno-fmt-ignore-file// deno-lint-ignore-file
// Copyright Joyent and Node contributors. All rights reserved. MIT license.// Taken from Node 18.12.0// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
'use strict';
const common = require('../common');const assert = require('assert');const net = require('net');
{ 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(() => { assert(!socket.destroyed); })); socket.on('close', common.mustCall()); }));}
{ 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(); })); }));}
Version Info