mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
PR-URL: https://github.com/nodejs/node/pull/60412 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
21 lines
588 B
JavaScript
21 lines
588 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const server = net.createServer(common.mustCall((socket) => {
|
|
assert.strictEqual(socket.remotePort, common.PORT);
|
|
socket.end();
|
|
socket.on('close', function() {
|
|
server.close();
|
|
});
|
|
})).listen(0).on('listening', common.mustCall(function() {
|
|
const client = net.connect({
|
|
host: '127.0.0.1',
|
|
port: this.address().port,
|
|
localPort: common.PORT,
|
|
}).on('connect', common.mustCall(() => {
|
|
assert.strictEqual(client.localPort, common.PORT);
|
|
}));
|
|
}));
|