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