mirror of https://github.com/lukechilds/node.git
Browse Source
net.connect() accepts `{ port: "1234" }` (i.e. a string) as of commit
9d2b89d06
("net: allow port 0 in connect()") but net.Server#listen()
did not, creating a minor inconsistency. This commit rectifies that.
Fixes: https://github.com/iojs/io.js/issues/1111
PR-URL: https://github.com/iojs/io.js/pull/1116
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v1.8.0-commit
Ben Noordhuis
10 years ago
2 changed files with 51 additions and 13 deletions
@ -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); |
||||
|
}); |
Loading…
Reference in new issue