1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Move udp sock error listener to only be instantiated once.

This commit is contained in:
Dave Conway-Jones 2017-06-23 16:20:28 +01:00
parent dc9fa81346
commit 82d9a02d92
No known key found for this signature in database
GPG Key ID: 81B04231572A9A2D

View File

@ -130,15 +130,15 @@ module.exports = function(RED) {
} }
else { else {
sock = dgram.createSocket(opts); // default to udp4 sock = dgram.createSocket(opts); // default to udp4
udpInputPortsInUse[this.outport] = sock;
}
sock.on("error", function(err) { sock.on("error", function(err) {
// Any async error will also get reported in the sock.send call. // Any async error will also get reported in the sock.send call.
// This handler is needed to ensure the error marked as handled to // This handler is needed to ensure the error marked as handled to
// prevent it going to the global error handler and shutting node-red // prevent it going to the global error handler and shutting node-red
// down. // down.
}); });
udpInputPortsInUse[this.outport] = sock;
}
if (node.multicast != "false") { if (node.multicast != "false") {
if (node.outport === "") { node.outport = node.port; } if (node.outport === "") { node.outport = node.port; }
sock.bind(node.outport, function() { // have to bind before you can enable broadcast... sock.bind(node.outport, function() { // have to bind before you can enable broadcast...