Test and fix for self-assigned port from net.Server

This commit is contained in:
Ryan Dahl 2010-11-15 20:22:54 -08:00
parent 939fba40fd
commit 4144024e6b
2 changed files with 20 additions and 1 deletions

View File

@ -1075,7 +1075,7 @@ Server.prototype.listen = function () {
self.addListener('listening', lastArg);
}
var port = toPort(arguments[0]);
var port = toPort(arguments[0] != lastArg ? arguments[0] : null);
if (port === false) {
// the first argument specifies a path
self.fd = socket('unix');

View File

@ -0,0 +1,19 @@
var common = require('../common');
net = require('net');
assert = require('assert');
var address;
var server = net.createServer(function (socket) {
});
server.listen(function() {
address = server.address();
console.log("opened server on %j", address);
server.close();
});
process.on('exit', function () {
assert.ok(address.port > 100);
});