Skip to content

Commit

Permalink
Revert "[fix] always listen to wildcard address"
Browse files Browse the repository at this point in the history
This reverts commit 19decba.

Conflicts:

	lib/net.js
  • Loading branch information
mmalecki committed May 2, 2012
1 parent 19982f5 commit c9f31ba
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions lib/net.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@ function toPort(x) {
return (x = Number(x)) >= 0 ? x : false; return (x = Number(x)) >= 0 ? x : false;
} }


//
// ### function nextPort (port)
// #### @port {Number} Port to increment from.
// Gets the next port in sequence from the
// specified `port`.
//
function nextPort(port) {
if (!port) {
return 8000;
}

//
// Find the next port that we are not supposed to ignore or cause errors on
//
var unavailable = carapace.ports.ignore.concat(carapace.ports.throw);
do {
port = port + 1;
} while (unavailable.indexOf(port) !== -1);

return port;
}

// //
// ### functon reservedPort // ### functon reservedPort
// #### @desired {Number} Desired port to bind to. // #### @desired {Number} Desired port to bind to.
Expand Down Expand Up @@ -88,18 +110,18 @@ exports._doListen = function overrideNet() {
// Since desired is not on a throwing port // Since desired is not on a throwing port
// we want to skip ports in both throw and ignore // we want to skip ports in both throw and ignore
// //
current = 0; current = desired ? desired : nextPort(desired);


for (;;) { for (;;) {
try { try {
binding.bind(self.fd, 0, '0.0.0.0'); binding.bind(self.fd, current, addr);
break; break;
} }
catch (err) { catch (err) {
// //
// Find the next port we are not supposed to throw up on or ignore // Find the next port we are not supposed to throw up on or ignore
// //
current = 0; current = nextPort(current);


// //
// If this is not an `EADDRINUSE` error or the port is in // If this is not an `EADDRINUSE` error or the port is in
Expand Down Expand Up @@ -290,7 +312,7 @@ exports._listen2 = function overrideNet() {
// Call original _listen2 function. // Call original _listen2 function.
// //
process.nextTick(function () { process.nextTick(function () {
_listen2.call(self, '0.0.0.0', 0, addressType); _listen2.call(self, address, port, addressType);
}); });
}; };
}; };
Expand Down

0 comments on commit c9f31ba

Please sign in to comment.