2015-05-19 19:00:06 +08:00
|
|
|
'use strict';
|
2016-12-02 00:25:05 +08:00
|
|
|
const common = require('../common');
|
|
|
|
const net = require('net');
|
|
|
|
const assert = require('assert');
|
2014-12-03 11:16:32 +08:00
|
|
|
|
2016-12-02 00:25:05 +08:00
|
|
|
const c = net.createConnection(common.PORT);
|
2014-12-03 11:16:32 +08:00
|
|
|
|
2017-02-04 03:54:19 +08:00
|
|
|
c.on('connect', common.mustNotCall());
|
2014-12-03 11:16:32 +08:00
|
|
|
|
2023-02-23 17:55:04 +08:00
|
|
|
c.on('error', common.mustCall(function(error) {
|
|
|
|
// Family autoselection might be skipped if only a single address is returned by DNS.
|
|
|
|
const failedAttempt = Array.isArray(error.errors) ? error.errors[0] : error;
|
|
|
|
|
|
|
|
assert.strictEqual(failedAttempt.code, 'ECONNREFUSED');
|
|
|
|
assert.strictEqual(failedAttempt.port, common.PORT);
|
|
|
|
assert.match(failedAttempt.address, /^(127\.0\.0\.1|::1)$/);
|
2014-12-03 11:16:32 +08:00
|
|
|
}));
|