about bug #121 (binding on the requested network interface)

Help
2013-05-24
2013-05-24
  • Arjun Panday
    Arjun Panday
    2013-05-24

    Sorry, Apparently I can't comment directly on the bug tracker.
    I'm refering to:
    https://sourceforge.net/p/jmdns/bugs/121/

    I've had the same problem on our cluster.

    Just meant to say that the following patch in HostInfo.java seems to resolve the issue:

                    _interfaze = NetworkInterface.getByInetAddress(address);
                    for (Enumeration<NetworkInterface> e = _interfaze.getSubInterfaces(); e.hasMoreElements(); ) {
                      NetworkInterface sub = e.nextElement();
                      for (Enumeration<InetAddress> ee = sub.getInetAddresses(); ee.hasMoreElements(); ) {
                        InetAddress ad = ee.nextElement();
                        if (ad.equals(address)) _interfaze = sub;
                      }
    

    I must admit the Java API is ugly and it's rather awkward that NetworkInterface.getByInetAddress doesn't directly return the correct subinterface.

    Hope this helps.
    BR,
    Arjun