Better logic for testing if an argument is a port
If you did server.listen('123') it would open a socket in the current directory called 123. Now it will interpret it as a port.
This commit is contained in:
parent
d38d96eb61
commit
1d28cfcfb9
@ -759,6 +759,8 @@ function doConnect (socket, port, host) {
|
||||
};
|
||||
}
|
||||
|
||||
function isPort (x) { return parseInt(x) >= 0; }
|
||||
|
||||
|
||||
// var stream = new Stream();
|
||||
// stream.connect(80) - TCP connect to port 80 on the localhost
|
||||
@ -774,7 +776,7 @@ Stream.prototype.connect = function () {
|
||||
|
||||
self._connecting = true; // set false in doConnect
|
||||
|
||||
if (parseInt(arguments[0]) >= 0) {
|
||||
if (isPort(arguments[0])) {
|
||||
// TCP
|
||||
var port = arguments[0];
|
||||
dns.lookup(arguments[1], function (err, ip, addressType) {
|
||||
@ -991,7 +993,7 @@ Server.prototype.listen = function () {
|
||||
var self = this;
|
||||
if (self.fd) throw new Error('Server already opened');
|
||||
|
||||
if (typeof(arguments[0]) == 'string') {
|
||||
if (!isPort(arguments[0])) {
|
||||
// the first argument specifies a path
|
||||
self.fd = socket('unix');
|
||||
self.type = 'unix';
|
||||
|
Loading…
x
Reference in New Issue
Block a user