Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -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

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.


// where to send address
InetSocketAddress[] broadcastAddresses = InetAddressUtil.getBroadcastAddresses(broadcastPort);
Expand All @@ -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

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.


// set broadcast address list
if (addressList != null && addressList.length() > 0) {
Expand Down Expand Up @@ -478,7 +479,7 @@ private void initializeUDPTransport() {
broadcastTransport.start();
searchTransport.start();

} catch (ConnectionException ce) {
} catch (ConnectionException | UnknownHostException ce) {
logger.log(Level.SEVERE, "Failed to initialize UDP transport.", ce);
}
}
Expand Down