node/test/parallel/test-net-connect-reset.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
309 B
JavaScript

'use strict';
const common = require('../common');
const net = require('net');
const socket = new net.Socket();
socket.resetAndDestroy();
// Emit error if socket is not connecting/connected
socket.on('error', common.mustCall(
common.expectsError({
code: 'ERR_SOCKET_CLOSED',
name: 'Error'
}))
);