Skip to content

Conversation

pjyoung
Copy link

@pjyoung pjyoung commented Jan 16, 2024

I have submitted this fix for the issue 130 I raised nearly a year ago. Hopefully it can be merged into the master

@shroffk shroffk requested a review from Copilot July 23, 2025 15:03
Copy link

@Copilot Copilot AI left a 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);
Copy link
Preview

Copilot AI Jul 23, 2025

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);
Copy link
Preview

Copilot AI Jul 23, 2025

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.

@shroffk
Copy link
Contributor

shroffk commented Jul 23, 2025

Did the following suggestion work?
#130 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants