mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
fix tcp node new Buffer alloc size 0
This commit is contained in:
parent
aa7fe3668c
commit
4dd2d3ac7d
@ -47,7 +47,7 @@ module.exports = function(RED) {
|
|||||||
node.status({fill:"grey",shape:"dot",text:"common.status.connecting"});
|
node.status({fill:"grey",shape:"dot",text:"common.status.connecting"});
|
||||||
var id = (1+Math.random()*4294967295).toString(16);
|
var id = (1+Math.random()*4294967295).toString(16);
|
||||||
client = net.connect(node.port, node.host, function() {
|
client = net.connect(node.port, node.host, function() {
|
||||||
buffer = (node.datatype == 'buffer') ? new Buffer.from(0) : "";
|
buffer = (node.datatype == 'buffer') ? new Buffer.alloc(0) : "";
|
||||||
node.connected = true;
|
node.connected = true;
|
||||||
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
|
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
|
||||||
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
|
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
|
||||||
@ -132,7 +132,7 @@ module.exports = function(RED) {
|
|||||||
count++;
|
count++;
|
||||||
node.status({text:RED._("tcpin.status.connections",{count:count})});
|
node.status({text:RED._("tcpin.status.connections",{count:count})});
|
||||||
|
|
||||||
var buffer = (node.datatype == 'buffer') ? new Buffer.from(0) : "";
|
var buffer = (node.datatype == 'buffer') ? new Buffer.alloc(0) : "";
|
||||||
socket.on('data', function (data) {
|
socket.on('data', function (data) {
|
||||||
if (node.datatype != 'buffer') {
|
if (node.datatype != 'buffer') {
|
||||||
data = data.toString(node.datatype);
|
data = data.toString(node.datatype);
|
||||||
|
Loading…
Reference in New Issue
Block a user