-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for Port Binding Conflicts in ArtNetClient and ArtNetServer #27
base: master
Are you sure you want to change the base?
Conversation
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.
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.
This reverts commit 43f696c.
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.
You know what... this commit is not suitable for main branch after testing and thinking through further. This commit would cause a breaking change and require updating existing code beacuse passing null into Sorry I didn't catch this before sending the PR. I will close for now and push another one that retains the pre-existing behavior when |
Fixing the issue now it's a one line change. |
Alright, it's safe now. |
This PR addresses an issue (#26) where the
ArtNetClient
andArtNetServer
classes were causing port binding conflicts when used as a sender and receiver simultaneously on the same machine. By introducing a new parameter to control whether the client/server should bind to a port or use an ephemeral port, we resolve the conflicts and improve the flexibility of the library.Changes Made:
ArtNetClient.java:
start(boolean isReceiver)
method to allow specifying the mode (sender or receiver) directly.start
methods to preserve backward compatibility and default to using the input buffer to determine the receiver mode.ArtNetServer.java:
start
method to accept aboolean isReceiver
parameter to control whether to bind to the specified port or use an ephemeral port.Testing:
ArtNetClient
can be started as a sender usingartnet.start(false)
.Documentation:
Usage Example:
To start an
ArtNetClient
as a sender (without port binding):Backward Compatibility:
true
for receiver mode when not specified.Conclusion:
These changes improve the flexibility and usability of the
artnet4j
library by resolving port binding conflicts and allowing users to specify the mode of the client/server.I really needed this behavior for my own application so I didn't go too deeply into an optimal fix. A better solution may be to infer if the connection is a reciever or sender somehow, but this was beyond the limits of what I had time for and to be honest my Java is not that great.
If the maintainers feel like this solution is adequate though, great!
All the best,
-T