-
Notifications
You must be signed in to change notification settings - Fork 11
Fix for issue 130 #139
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
base: master
Are you sure you want to change the base?
Fix for issue 130 #139
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue 130 by fixing UDP transport initialization to properly bind to all network interfaces. The changes modify socket address creation to explicitly use "0.0.0.0" instead of relying on default behavior, and adds proper exception handling for hostname resolution failures.
- Explicitly binds UDP transport to all interfaces using "0.0.0.0"
- Adds exception handling for UnknownHostException during network initialization
- Updates both listen and search transport socket creation for consistency
@@ -418,7 +419,7 @@ private void initializeUDPTransport() { | |||
// setup UDP transport | |||
try { | |||
// where to bind (listen) address | |||
InetSocketAddress listenLocalAddress = new InetSocketAddress(broadcastPort); | |||
InetSocketAddress listenLocalAddress = new InetSocketAddress(InetAddress.getByName("0.0.0.0"), broadcastPort); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded IP address "0.0.0.0" should be extracted to a named constant to improve maintainability and make the intent clearer.
Copilot uses AI. Check for mistakes.
@@ -432,7 +433,7 @@ private void initializeUDPTransport() { | |||
BlockingUDPConnector searchConnector = new BlockingUDPConnector(this, false, broadcastAddresses, true); | |||
|
|||
searchTransport = (BlockingUDPTransport) searchConnector.connect(null, new ClientResponseHandler(this), | |||
new InetSocketAddress(0), PVAConstants.PVA_PROTOCOL_REVISION, PVAConstants.PVA_DEFAULT_PRIORITY); | |||
new InetSocketAddress(InetAddress.getByName("0.0.0.0"), 0), PVAConstants.PVA_PROTOCOL_REVISION, PVAConstants.PVA_DEFAULT_PRIORITY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded IP address "0.0.0.0" should be extracted to a named constant to avoid duplication and improve maintainability.
Copilot uses AI. Check for mistakes.
Did the following suggestion work? |
I have submitted this fix for the issue 130 I raised nearly a year ago. Hopefully it can be merged into the master