I'm trying to listen on a tcp port that is sending continuous streams of data separated by curly braces { x, y, z}. When I run this script with node, I get the first console output "client connected", but the rest of the script hangs. Is there anything I can do to display the data as it arrives??
var s = require('net');
var client = s.connect(2324, '10.12.1.22', function(){
console.log('client connected');
});
client.on('data', function(d){
console.log(d);
});
client.end();
client.end()before data can be received, you should putclient.end();inside thedataevent. and I believe you needs.close()ors.end()