https://bugs.documentfoundation.org/show_bug.cgi?id=115503

            Bug ID: 115503
           Summary: Broadcast address
           Product: Impress Remote
           Version: 2.2.3
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: Android app
          Assignee: libreoffice-bugs@lists.freedesktop.org
          Reporter: michael.m...@gmx.de

The built-in fixed broadcast address

   public static final String SERVER_SEARCH = "239.0.0.1";

does not work reliably.

I propose to use the following method to find the broadcast address:

   private InetAddress getBroadcastAddress() {
        try {
            for (NetworkInterface ni :
Collections.list(NetworkInterface.getNetworkInterfaces())) {
                if (ni.isUp()) {
                    for (InterfaceAddress addr : ni.getInterfaceAddresses()) {
                        if (!addr.getAddress().isLoopbackAddress()) {
                            return addr.getBroadcast();
                        }
                    }
                }
            }
        } catch (SocketException ex) {
            // ignore
        }
        throw new RuntimeException("no broadcast address found");
    }

In the class "TcpServersFinder" the method buildSearchPacket could use this
method:

    private DatagramPacket buildSearchPacket() {
        String aSearchCommand = Protocol.Commands
            .prepareCommand(Protocol.Commands.SEARCH_SERVERS);

        DatagramPacket aSearchPacket = new DatagramPacket(
            aSearchCommand.getBytes(), aSearchCommand.length());

        aSearchPacket.setAddress(getBroadcastAddress());
        aSearchPacket.setPort(Protocol.Ports.SERVER_SEARCH);

        return aSearchPacket;
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to