Hello,
I've found an issue while using UDP in/out with broadcasting.
The scenario:
- udp in listening on port 57066
- udp out sending a broadcast packet and binding to local port 57066
(the goal is to discover another device IP address, and this device will reply when receiving a specific packet on a specific port).
When the udp out tries to send the message, it throws an EACCES error. This is because the SO_BROADCAST flag is not set.
Looking at the code, I see that udp out will reuse the socket of udp in if it already exists. But this socket will not have the broadcast flag.
If I change the code in the UDPout function by updating the code below, it works:
node.tout = setTimeout(function() {
if (udpInputPortsInUse[p]) {
sock = udpInputPortsInUse[p];
// start of modification:
if (node.multicast == "broad") {
sock.setBroadcast(true);
sock.setMulticastLoopback(false);
}
// end of modification
node.log(RED._("udp.status.re-use",{outport:node.outport,host:node.addr,port:node.port}));
if (node.iface) { node.status({text:n.iface+" : "+node.iface}); }
}
What do you guys think? Is it bug that could be corrected, or am I missing something?