3

I'm trying to find the address that matches a resolved Bonjour service that is registered to a specific network interface.

DNSSD gives me the hostname and the network interface index of a service: ifIndex. If the host has multiple network interfaces, I have to find out which of the network interfaces belongs to the ifIndex that this service is registered to (assuming that the service's ifIndex is not 0 or -1).

public void serviceResolved(DNSSDService resolver, int flags, int ifIndex, String fullName, String hostName, int port, TXTRecord txtRecord) {
    InetAddress[] addresses = null;
    try {
        addresses = InetAddress.getAllByName(hostName);
    } catch (UnknownHostException e) {}

    for (InetAddress address : addresses) {
        //How do I know what the appropriate address is?
    }
}

Does anyone know how to find out which of the ip addresses of the resolved hostname belongs to the resolved ifIndex?

Many thanks, Mattijs

Mattijs
  • 1,909
  • 3
  • 19
  • 28

0 Answers0