From 53e5404b1637ae0b8f86fb850300377fe6d4c633 Mon Sep 17 00:00:00 2001 From: visionmedia Date: Wed, 30 Dec 2009 08:48:32 -0800 Subject: [PATCH] Mirror nodes server.listen() params [#111] Consistency and adds backlog param --- lib/express/core.js | 20 ++++++++++++++------ lib/express/dsl.js | 10 ++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/express/core.js b/lib/express/core.js index 0f33f92057..ada5ef230a 100644 --- a/lib/express/core.js +++ b/lib/express/core.js @@ -180,28 +180,36 @@ Server = Class({ port: 3000, /** - * Default host ip. + * Default host ip, when null node will accept requests on + * all network addresses. */ host: 'localhost', /** - * Run Express at _host_ and _port_, otherwise - * falling back on the defaults. + * Maximum number of queued connections. + */ + + backlog: 128, + + /** + * Run Express. * * - Buffers request bodies * - Calls #route() once the request is complete * - * @param {string} host * @param {int} port + * @param {string} host + * @param {int} backlog * @see run() * @api private */ - run: function(host, port){ + run: function(port, host, backlog){ var self = this if (host !== undefined) this.host = host if (port !== undefined) this.port = port + if (backlog !== undefined) this.backlog = backlog require('http') .createServer(function(request, response){ request.body = '' @@ -209,7 +217,7 @@ Server = Class({ request.addListener('body', function(chunk){ request.body += chunk }) request.addListener('complete', function(){ self.route(request, response) }) }) - .listen(this.port, this.host) + .listen(this.port, this.host, this.backlog) puts('Express started at http://' + this.host + ':' + this.port + '/ in ' + Express.environment + ' mode') }, diff --git a/lib/express/dsl.js b/lib/express/dsl.js index 9dfde39347..cdbd6e7093 100644 --- a/lib/express/dsl.js +++ b/lib/express/dsl.js @@ -58,20 +58,18 @@ exports.disable = function(option) { } /** - * Run Express with the given _host_ and _port_ - * or the defaults will be used. + * Run Express, view Server#run() for parameters. * * All configuration handlers for EXPRESS_ENV or 'development' * are called before starting the server. * - * @param {string} host - * @param {int} port + * @see Server#run() * @api public */ -exports.run = function(host, port) { +exports.run = function() { configure(Express.environment = process.ENV.EXPRESS_ENV || 'development') - Express.server.run(host, port) + Express.server.run.apply(Express.server, arguments) } /**