<commit_before>
// Set up the TCP socket for the bridge
var net = require('net')
    ,util = require('util')
    ;

var CB = require('./index');

/* TCP socket manager */

function TCPSocket(port) {

    var self = this;

    this.server = net.createServer(function(socket) {

        socket.setEncoding('utf8');

        self.on('message', function(message) {

            logger.log('debug', 'TCP socket:', message);
            //var jsonMessage = message.getJSON();
        });

        socket.on('data', function(jsonMessage) {

            var message = new Message(jsonMessage);
            self.emit(message);
        }); 

        // Add a 'close' event handler for the TCPClient socket
        socket.on('close', function() {

            socket.removeListener('data');
            self.removeListener('message');
            logger.info('TCP socket disconnected');
        }); 

        self.socket = socket;

        logger.info('TCP socket connected');

    }).listen(port);
}
<commit_msg>TCP socket can deal with concatenation of json messages<commit_after>
// Set up the TCP socket for the bridge
var net = require('net')
    ,util = require('util')
    ;

var CB = require('./index');

/* TCP socket manager */

function TCPSocket(port) {

    var self = this;

    this.server = net.createServer(function(socket) {

        socket.setEncoding('utf8');

        self.on('message', function(message) {

            logger.log('debug', 'TCP socket:', message);
            //var jsonMessage = message.getJSON();
        });

        socket.on('data', function(jsonMessage) {

            // There may be multiple messages in each chunk of TCP data.
            var messageArray = JSON.parse('[' + jsonMessage + ']');

            _.each(messageArray, function(message) {
                console.log('Received message', message);
                var message = new Message(message);
                self.emit('message', message);
            });
        }); 

        // Add a 'close' event handler for the TCPClient socket
        socket.on('close', function() {

            socket.removeListener('data');
            self.removeListener('message');
            logger.info('TCP socket disconnected');
        }); 

        self.socket = socket;

        logger.info('TCP socket connected');

    }).listen(port);
}

{'fraction_non_alphanumeric': 0.1386266094420601, 'fraction_numerical': 0.0008583690987124463, 'mean_word_length': 2.1330645161290325, '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': '7167792', 'n_tokens_mistral': 626, 'n_tokens_neox': 592, 'n_words': 161}