Skip to content

Commit

Permalink
Allow port=0 to let the kernel choose a random unprivileged port.
Browse files Browse the repository at this point in the history
  • Loading branch information
janpieper committed Jan 11, 2012
1 parent 189f92d commit ede7cf4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Server.prototype.removeClient = function(client){
Server.prototype.listen = function(port, host){
net.Server.prototype.listen.call(
this
, port || defaultPort
, port === 0 || port ? port : defaultPort
, host || defaultHost);
return this;
};
7 changes: 3 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@

var nedis = require('../')
, net = require('net')
, fs = require('fs')
, port = 8888;
, fs = require('fs');

/**
* Server.
*/

var server = nedis.createServer().listen(port);
var server = nedis.createServer().listen(0);

server.on('listening', function(){

/**
* Client.
*/

var client = net.createConnection(port);
var client = net.createConnection(server.address().port);

/**
* Timeout support.
Expand Down

0 comments on commit ede7cf4

Please sign in to comment.