Skip to content

Commit

Permalink
Merge pull request #795 from pavkriz/master
Browse files Browse the repository at this point in the history
Allow 'backlog' option for listening socket
  • Loading branch information
JacksonTian committed Jul 28, 2016
2 parents 4167e5c + df2ebff commit 6aa67c8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/WebSocketServer.js
Expand Up @@ -41,7 +41,8 @@ function WebSocketServer(options, callback) {
disableHixie: false,
clientTracking: true,
perMessageDeflate: true,
maxPayload: 100 * 1024 * 1024
maxPayload: 100 * 1024 * 1024,
backlog: null // use default (511 as implemented in net.js)
}, options);

if (!isDefinedAndNonNull(options, 'port') && !isDefinedAndNonNull(options, 'server') && !options.noServer) {
Expand All @@ -60,7 +61,12 @@ function WebSocketServer(options, callback) {
res.end(body);
});
this._server.allowHalfOpen = false;
this._server.listen(options.port, options.host, callback);
// maybe use a generic server.listen(options[, callback]) variant here, instead of two overloaded variants?
if (isDefinedAndNonNull(options, 'backlog')) {
this._server.listen(options.port, options.host, options.backlog, callback);
} else {
this._server.listen(options.port, options.host, callback);
}
this._closeServer = function() {
if (self._server)
self._server.close();
Expand Down

0 comments on commit 6aa67c8

Please sign in to comment.