Open tylerstraub opened 6 months ago
PR sent: https://github.com/cansik/artnet4j/pull/27
This branch implements a boolean option to start()
which launches the port binding in "ephemeral mode".
I'm not sure if this fix is necessarily ideal for main branch but it exists now for anyone out there struggling with this same problem.
When using the artnet4j library in a Processing 4 application, the library creates a UDP port binding even when acting as an ArtNet Sender. This behavior leads to binding conflicts with other applications that may need to communicate locally, such as DigiShow LINK and QLC+, which do not bind to a specific port when sending ArtNet data.
Expected Behavior
ArtNet Sender applications should use an ephemeral port for sending data and should not bind to a specific port (e.g. 6454). Only ArtNet Receiver applications require a static bind to listen for incoming ArtNet packets.
Observed Behavior
The artnet4j library binds a port regardless of whether it is used as a Sender or Receiver. This causes conflicts when other applications attempt to bind to the same port.
Steps to Reproduce
Condition 1: Sender = Processing 4, Receiver = DigiShow LINK
Condition 2: Receiver = Processing 4, Sender = DigiShow LINK
Extra Tests:
Diagnostic Results
Using
lsof
on macOS reveals that DigiShow LINK does not create a binding when sending ArtNet, but the Processing 4 application using artnet4j does:DigiShow LINK as Sender (no binding):
Output: (empty)
Processing 4 as Sender (binding occurs):
Validation of Ephemeral Port Usage in DigiShow LINK
After examining the DigiShow LINK source code, it was confirmed that DigiShow LINK uses ephemeral ports for sending ArtNet data. This approach prevents port conflicts and allows the application to coexist with other applications that need to bind as a Reciever.
Key Points from
dgs_artnet_interface.cpp
:UDP Port Definition:
UDP Socket Initialization:
Binding the UDP Socket for Input:
Setting Up the UDP Socket for Output:
Suggested Fix
Modify the artnet4j library to avoid static binding its port when acting solely as a Sender. Instead, it should use an ephemeral port for sending data.
Proposed Code Changes
Here is an example modification to the
ArtNetServer
class:In the application code, specify whether the instance is acting as a Sender or Receiver:
Conclusion
By implementing these changes, the artnet4j library will avoid unnecessary port bindings when acting as a Sender, preventing conflicts with other applications and allowing for more flexible execution order.