Browse Source

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

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
4144024e6b
  1. 2
      lib/net.js
  2. 19
      test/simple/test-net-server-listen-assigned-port.js

2
lib/net.js

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

19
test/simple/test-net-server-listen-assigned-port.js

@ -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);
});
Loading…
Cancel
Save