<commit_before>var net          = require('net');
var util         = require('util');
var EventEmitter = require('events').EventEmitter;

var PacketParser = require('./packet_parser');
var Packet       = require('./packets/packet');
var Commands     = require('./commands/index.js');
var Connection   = require('./connection');
var ConnectionConfig = require('./connection_config');

// TODO: inherit Server from net.Server
function Server()
{
  EventEmitter.call(this);
  this.connections = [];
  this._server = net.createServer(this._handleConnection.bind(this));
}
util.inherits(Server, EventEmitter);

Server.prototype._handleConnection = function(socket) {
  var connectionConfig = new ConnectionConfig({ stream: socket, isServer: true});
  var connection = new Connection({ config: connectionConfig});
  this.emit('connection', connection);
  this.connections.push(connection);
};

Server.prototype.listen = function(port, host, backlog, callback) {
  this._server.listen.apply(this._server, arguments);
};

module.exports = Server;<commit_msg>make listen chainable<commit_after>var net          = require('net');
var util         = require('util');
var EventEmitter = require('events').EventEmitter;

var PacketParser = require('./packet_parser');
var Packet       = require('./packets/packet');
var Commands     = require('./commands/index.js');
var Connection   = require('./connection');
var ConnectionConfig = require('./connection_config');

// TODO: inherit Server from net.Server
function Server()
{
  EventEmitter.call(this);
  this.connections = [];
  this._server = net.createServer(this._handleConnection.bind(this));
}
util.inherits(Server, EventEmitter);

Server.prototype._handleConnection = function(socket) {
  var connectionConfig = new ConnectionConfig({ stream: socket, isServer: true});
  var connection = new Connection({ config: connectionConfig});
  this.emit('connection', connection);
  this.connections.push(connection);
};

Server.prototype.listen = function(port, host, backlog, callback) {
  this._server.listen.apply(this._server, arguments);
  return this;
};



module.exports = Server;
{'fraction_non_alphanumeric': 0.14635294117647057, 'fraction_numerical': 0.0, 'mean_word_length': 4.988732394366197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7409561', 'n_tokens_mistral': 569, 'n_tokens_neox': 565, 'n_words': 133}