I close the file using tail-always
and transferring data to another server using the TLS socket in node. Here is the code that passes the strings to another server
var client = tls.connect(port,serveraddress, options, function() {
tail.on('line', function(data) {
console.log(data.toString('utf-8'))
client.write(data.toString('utf-8'));
});
tail.on('error', function(data) {
console.log("error:", data);
});
tail.watch();
});
on another side server listens on the port and captures the text. the code:
var server = tls.createServer(options, function(tslsender) {
tslsender.on('data', function(data) {
console.log(data.toString('utf-8'));
});
tslsender.on('close', function() {
console.log('closed connection');
});
});
The program works great when one line is added at a time to the file, but when several lines are added to the file, the lines are combined on the server side. I confirmed that they are not concatenated to client.write .
how can i solve this problem?
anand source
share