I'm trying to send a string from Node.js to a Java server but nothing will send from the Node.js client unless I call client.end() after. I'm not very experienced with Node.js so any suggestions would help.
var net = require('net');
var client = net.connect(1032, 'localhost')
client.on('connect', function(){
console.log('connected');
});
client.on('data', function(data){
console.log(data.toString());
client.write('test reply');
});
client.on('close', function(){
client.end();
});
答案 0 :(得分:1)
var net = require('net');
var client = net.connect(1032, 'localhost')
client.on('connect', function(){
console.log('connected');
client.write('test reply');
});
client.on('data', function(data){
console.log(data.toString());
});
client.on('close', function(){
client.end();
});