From 2fe568d9ba9cb7ded2d5cc4ee0209491568470a5 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 17 Aug 2015 17:15:44 +0100 Subject: [PATCH] Fix TCP node sending data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (it’s for the children) --- nodes/core/io/31-tcpin.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index b1fb582b0..f39e5ddc1 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -432,7 +432,7 @@ module.exports = function(RED) { m = new Buffer(i+1); buf.copy(m,0,0,i+1); node.send({"payload":m}); - if (client) { client.end(); } + //if (client) { client.end(); } }, node.splitc); i = 0; buf[0] = data[j]; @@ -445,7 +445,8 @@ module.exports = function(RED) { if ( i >= node.splitc) { m = new Buffer(i); buf.copy(m,0,0,i); - if (client) { client.end(); } + node.send({"payload":m}); + //if (client) { client.end(); } i = 0; } } @@ -456,7 +457,8 @@ module.exports = function(RED) { if (data[j] == node.splitc) { m = new Buffer(i); buf.copy(m,0,0,i); - if (client) { client.end(); } + node.send({"payload":m}); + //if (client) { client.end(); } i = 0; } } @@ -472,6 +474,7 @@ module.exports = function(RED) { }); client.on('close', function() { + node.status({}); if (node.done) { node.done(); } }); @@ -501,7 +504,7 @@ module.exports = function(RED) { node.done = done; if (client) { buf = null; - client.end(); + client.destroy(); } if (!node.connected) { done(); } });