Closed kjkmr closed 7 months ago
I think localAddress: "0.0.0.0"
is the canonical way to bind to all local addresses available.
Thank you. That worked correctly. Then why the default value is "127.0.0.1" ? I think it should be "0.0.0.0".
If it helps any, @kjkmr, my rationale for defaulting to localhost is that I think generally defaults should be conservative, and do the least impactful thing out of the box. Whether I should have followed Node.js' underlying implementation is a good question, and I'm really not sure what the right answer to this is—but I do know that changing this default, which has been in place for over a decade, would be an API-breaking change.
By the way, I just wanted to say thanks for filing such a detailed ticket, I appreciate it. And thanks @jean-emmanuel for your response!
With this code, I can receive messages to “localhost” but not to “127.0.0.1” and “192.168.0.100” (local IP address).
The localAddress must be exact same string to receive. If I left the localAddress undefined, this library put default value “127.0.0.1” to it. So with this setting, I can receive the message to "127.0.0.1", but I can't receive messages to "localhost" or broadcast and multicast address.
According to the official node.js document, it says "If address is not specified, the operating system will attempt to listen on all addresses.”.
https://nodejs.org/api/dgram.html#socketbindport-address-callback
So, a dirty workaround for this problem is set options.localAddress to undefined before calling open().
With this workaround, I can correctly receive multicast and broadcast messages with the code below.
But for correct fix, I think the line below of src/platforms/osc-node.js (line:50) should be deleted.
I tested on Mac OS 13.4, node version 20.11.0 I hope this helps someone who are in the same problem. Thank you for a great library.