forked from thormartin91/twitter-stream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
34 lines (27 loc) · 776 Bytes
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// CLIENT
const net = require('net');
const socket = net.Socket();
// CONFIG
const CONFIG = require('./config.js');
socket.connect(CONFIG.PORT, CONFIG.HOST, function() {
console.log('Connected');
});
var counter = 0;
var start = new Date();
socket.on('data', function(data){
var items = data.toString().split('\r\n');
while (items.indexOf('') !== -1) {
items.splice(items.indexOf(''), 1);
}
counter += items.length;
console.log(items);
});
socket.on('end', function(data){
var end = new Date() - start;
console.info('Execution-time: \t', end, 'ms ~', (end/1000).toFixed(1), 's');
console.log('Recieved-count: \t', counter);
console.log('Frequency: \t\t', (counter/(end/1000)).toFixed(0), 't/s');
});
socket.on('error', function(err){
console.log(err);
});