From e206d2919e5f7e5c316edc4f1c77a0ae8a4752d1 Mon Sep 17 00:00:00 2001 From: dceejay Date: Sun, 19 Apr 2015 12:13:45 +0100 Subject: [PATCH] More defensive on closing tcp connections, and tidy up some lint --- nodes/core/io/31-tcpin.js | 43 +++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index c0c90a035..71498d7e9 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -59,17 +59,18 @@ module.exports = function(RED) { data = data.toString(node.datatype); } if (node.stream) { - if ((node.datatype) === "utf8" && node.newline != "") { + var msg; + if ((node.datatype) === "utf8" && node.newline !== "") { buffer = buffer+data; var parts = buffer.split(node.newline); for (var i = 0;i= node.serialConfig.count) { node.send({"payload": buf}); - client.end(); + if (client) { client.end(); } i = 0; } } @@ -449,7 +456,7 @@ module.exports = function(RED) { var m = new Buffer(i); buf.copy(m,0,0,i); node.send({"payload": m}); - client.end(); + if (client) { client.end(); } m = null; i = 0; }