diff --git a/lib/net.js b/lib/net.js index 478c04a1f83..5f324734921 100644 --- a/lib/net.js +++ b/lib/net.js @@ -62,8 +62,8 @@ function isPipeName(s) { } -exports.createServer = function() { - return new Server(arguments[0], arguments[1]); +exports.createServer = function(options, connectionListener) { + return new Server(options, connectionListener); }; @@ -984,23 +984,23 @@ function afterConnect(status, handle, req, readable, writable) { } -function Server(/* [ options, ] listener */) { - if (!(this instanceof Server)) return new Server(arguments[0], arguments[1]); +function Server(options, connectionListener) { + if (!(this instanceof Server)) + return new Server(options, connectionListener); + events.EventEmitter.call(this); var self = this; - var options; - - if (util.isFunction(arguments[0])) { + if (util.isFunction(options)) { + connectionListener = options; options = {}; - self.on('connection', arguments[0]); + self.on('connection', connectionListener); } else { - options = arguments[0] || {}; + options = options || {}; - if (util.isFunction(arguments[1])) { - self.on('connection', arguments[1]); - } + if (util.isFunction(connectionListener)) + self.on('connection', connectionListener); } this._connections = 0;