0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-net-connect-reset-before-connected.js
pupilTong 360cda1926 net: add ability to reset a tcp socket
Fixes: https://github.com/nodejs/node/issues/27428
PR-URL: https://github.com/nodejs/node/pull/43112
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-05-23 15:47:21 +02:00

14 lines
408 B
JavaScript

'use strict';
const common = require('../common');
const net = require('net');
const server = net.createServer();
server.listen(0);
const port = server.address().port;
const socket = net.connect(port, common.localhostIPv4, common.mustNotCall());
socket.on('error', common.mustNotCall());
server.close();
socket.resetAndDestroy();
// `reset` waiting socket connected to sent the RST packet
socket.destroy();