jdk/src/java.management/share/classes/sun/management/jdp/JdpBroadcaster.java
changeset 37324 78e60b834fa4
parent 26486 718b4d0243ab
equal deleted inserted replaced
37323:e41872ef1390 37324:78e60b834fa4
    97                 channel.bind(new InetSocketAddress(srcAddress, 0));
    97                 channel.bind(new InetSocketAddress(srcAddress, 0));
    98             } catch (UnsupportedAddressTypeException ex) {
    98             } catch (UnsupportedAddressTypeException ex) {
    99                 throw new JdpException("Unable to bind to source address");
    99                 throw new JdpException("Unable to bind to source address");
   100             }
   100             }
   101             channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
   101             channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
   102         } else {
       
   103             Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
       
   104             boolean succeed = false;
       
   105 
       
   106             while (nics.hasMoreElements()) {
       
   107                 NetworkInterface nic = nics.nextElement();
       
   108 
       
   109                 if (nic.isUp() && nic.supportsMulticast()) {
       
   110                     try {
       
   111                         channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, nic);
       
   112                         succeed = true;
       
   113                     } catch (IOException ex) {
       
   114                         // pass
       
   115                     }
       
   116                 }
       
   117 
       
   118             }
       
   119 
       
   120             if (!succeed) {
       
   121                 throw new JdpException("Unable to bind to any interfaces.");
       
   122             }
       
   123 
       
   124         }
   102         }
   125 
       
   126     }
   103     }
   127 
   104 
   128     /**
   105     /**
   129      * Create a new broadcaster
   106      * Create a new broadcaster
   130      *
   107      *