mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
update UDP node to not bind output port if not required to do so.
Fix to Close #165
This commit is contained in:
parent
46765d5737
commit
0bc4a3bbb1
@ -72,7 +72,6 @@
|
|||||||
color:"Silver",
|
color:"Silver",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: {value:""},
|
name: {value:""},
|
||||||
host: {value:""},
|
|
||||||
iface: {value:""},
|
iface: {value:""},
|
||||||
port: {value:"",required:true,validate:RED.validators.number()},
|
port: {value:"",required:true,validate:RED.validators.number()},
|
||||||
datatype: {value:"buffer",required:true},
|
datatype: {value:"buffer",required:true},
|
||||||
|
@ -22,7 +22,6 @@ function UDPin(n) {
|
|||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.group = n.group;
|
this.group = n.group;
|
||||||
this.port = n.port;
|
this.port = n.port;
|
||||||
this.host = n.host || null;
|
|
||||||
this.datatype = n.datatype;
|
this.datatype = n.datatype;
|
||||||
this.iface = n.iface || null;
|
this.iface = n.iface || null;
|
||||||
this.multicast = n.multicast;
|
this.multicast = n.multicast;
|
||||||
@ -64,7 +63,7 @@ function UDPin(n) {
|
|||||||
catch (err) { console.log(err); }
|
catch (err) { console.log(err); }
|
||||||
});
|
});
|
||||||
|
|
||||||
server.bind(node.port,node.host);
|
server.bind(node.port);
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("udp in",UDPin);
|
RED.nodes.registerType("udp in",UDPin);
|
||||||
|
|
||||||
@ -81,8 +80,9 @@ function UDPout(n) {
|
|||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
var sock = dgram.createSocket('udp4'); // only use ipv4 for now
|
var sock = dgram.createSocket('udp4'); // only use ipv4 for now
|
||||||
sock.bind(node.port); // have to bind before you can enable broadcast...
|
|
||||||
if (this.multicast != "false") {
|
if (this.multicast != "false") {
|
||||||
|
sock.bind(node.port, function() { // have to bind before you can enable broadcast...
|
||||||
sock.setBroadcast(true); // turn on broadcast
|
sock.setBroadcast(true); // turn on broadcast
|
||||||
if (this.multicast == "multi") {
|
if (this.multicast == "multi") {
|
||||||
sock.setMulticastTTL(128);
|
sock.setMulticastTTL(128);
|
||||||
@ -90,7 +90,9 @@ function UDPout(n) {
|
|||||||
node.log('udp multicast ready : '+node.addr+":"+node.port);
|
node.log('udp multicast ready : '+node.addr+":"+node.port);
|
||||||
}
|
}
|
||||||
else node.log('udp broadcast ready : '+node.addr+":"+node.port);
|
else node.log('udp broadcast ready : '+node.addr+":"+node.port);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
else node.log('udp ready : '+node.addr+":"+node.port);
|
else node.log('udp ready : '+node.addr+":"+node.port);
|
||||||
|
|
||||||
node.on("input", function(msg) {
|
node.on("input", function(msg) {
|
||||||
|
Loading…
Reference in New Issue
Block a user