2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-30 18:38:06 -05:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const net = require('net');
|
2014-02-17 17:30:12 -08:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const server = net.createServer(function(socket) {
|
2016-05-29 03:06:56 -04:00
|
|
|
assert.strictEqual(socket.remotePort, common.PORT);
|
2014-02-17 17:30:12 -08:00
|
|
|
socket.end();
|
|
|
|
socket.on('close', function() {
|
|
|
|
server.close();
|
|
|
|
});
|
2016-05-29 03:06:56 -04:00
|
|
|
}).listen(0).on('listening', function() {
|
2017-01-08 13:19:00 +00:00
|
|
|
const client = net.connect({
|
2014-02-17 17:30:12 -08:00
|
|
|
host: '127.0.0.1',
|
2016-05-29 03:06:56 -04:00
|
|
|
port: this.address().port,
|
|
|
|
localPort: common.PORT,
|
2014-02-17 17:30:12 -08:00
|
|
|
}).on('connect', function() {
|
2016-05-29 03:06:56 -04:00
|
|
|
assert.strictEqual(client.localPort, common.PORT);
|
2014-02-17 17:30:12 -08:00
|
|
|
});
|
2015-05-19 13:00:06 +02:00
|
|
|
});
|