Permalink
Browse files

support for setting server port to 0 (with test)

  • Loading branch information...
1 parent 3aed873 commit 8d6e58dbff7280f97fada9639c843594ba257217 @zanchin zanchin committed Oct 19, 2012
Showing with 16 additions and 1 deletion.
  1. +1 −1 index.js
  2. +15 −0 test/port0.js
View
2 index.js
@@ -108,7 +108,7 @@ dnode.prototype.listen = function () {
server.sessions = {};
- if (params.port) {
+ if (params.port !== undefined) {
server.listen(params.port, params.host);
}
else if (params.path) {
View
15 test/port0.js
@@ -0,0 +1,15 @@
+var dnode = require('../');
+var test = require('tap').test;
+
+test('port0', function (t) {
+ t.plan(2);
+ var port = 0;
+
+ var server = dnode().listen(port);
+
+ server.on('listening', function () {
+ t.ok(server.address().port !== port);
+ t.ok(server.address().port > 0);
+ server.close();
+ });
+});

0 comments on commit 8d6e58d

Please sign in to comment.