-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: allow server.listen({ port: "1234" })
net.connect() accepts `{ port: "1234" }` (i.e. a string) as of commit 9d2b89d ("net: allow port 0 in connect()") but net.Server#listen() did not, creating a minor inconsistency. This commit rectifies that. Fixes: #1111 PR-URL: #1116 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
1 parent
80e14d7
commit 480b482
Showing
2 changed files
with
51 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var net = require('net'); | ||
|
||
function close() { this.close(); } | ||
net.Server().listen({ port: undefined }, close); | ||
net.Server().listen({ port: '' + common.PORT }, close); | ||
|
||
[ 'nan', | ||
-1, | ||
123.456, | ||
0x10000, | ||
1 / 0, | ||
-1 / 0, | ||
'+Infinity', | ||
'-Infinity' ].forEach(function(port) { | ||
assert.throws(function() { | ||
net.Server().listen({ port: port }, assert.fail); | ||
}, /port should be >= 0 and < 65536/i); | ||
}); | ||
|
||
[null, true, false].forEach(function(port) { | ||
assert.throws(function() { | ||
net.Server().listen({ port: port }, assert.fail); | ||
}, /invalid listen argument/i); | ||
}); |