Skip to content

Commit

Permalink
Mirror nodes server.listen() params [expressjs#111]
Browse files Browse the repository at this point in the history
Consistency and adds backlog param
  • Loading branch information
tj committed Dec 30, 2009
1 parent 81ab164 commit 53e5404
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
20 changes: 14 additions & 6 deletions lib/express/core.js
Expand Up @@ -180,36 +180,44 @@ 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 = ''
request.setBodyEncoding('utf8')
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')
},

Expand Down
10 changes: 4 additions & 6 deletions lib/express/dsl.js
Expand Up @@ -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)
}

/**
Expand Down

0 comments on commit 53e5404

Please sign in to comment.