src/share/classes/java/net/NetworkInterface.java

Print this page




  36  * It is used to identify the local interface on which a multicast group
  37  * is joined.
  38  *
  39  * Interfaces are normally known by names such as "le0".
  40  *
  41  * @since 1.4
  42  */
  43 public final class NetworkInterface {
  44     private String name;
  45     private String displayName;
  46     private int index;
  47     private InetAddress addrs[];
  48     private InterfaceAddress bindings[];
  49     private NetworkInterface childs[];
  50     private NetworkInterface parent = null;
  51     private boolean virtual = false;
  52     private static final NetworkInterface defaultInterface;
  53     private static final int defaultIndex; /* index of defaultInterface */
  54 
  55     static {
  56         AccessController.doPrivileged(new LoadLibraryAction("net"));







  57         init();
  58         defaultInterface = DefaultInterface.getDefault();
  59         if (defaultInterface != null) {
  60             defaultIndex = defaultInterface.getIndex();
  61         } else {
  62             defaultIndex = 0;
  63         }
  64     }
  65 
  66     /**
  67      * Returns an NetworkInterface object with index set to 0 and name to null.
  68      * Setting such an interface on a MulticastSocket will cause the
  69      * kernel to choose one interface for sending multicast packets.
  70      *
  71      */
  72     NetworkInterface() {
  73     }
  74 
  75     NetworkInterface(String name, int index, InetAddress[] addrs) {
  76         this.name = name;




  36  * It is used to identify the local interface on which a multicast group
  37  * is joined.
  38  *
  39  * Interfaces are normally known by names such as "le0".
  40  *
  41  * @since 1.4
  42  */
  43 public final class NetworkInterface {
  44     private String name;
  45     private String displayName;
  46     private int index;
  47     private InetAddress addrs[];
  48     private InterfaceAddress bindings[];
  49     private NetworkInterface childs[];
  50     private NetworkInterface parent = null;
  51     private boolean virtual = false;
  52     private static final NetworkInterface defaultInterface;
  53     private static final int defaultIndex; /* index of defaultInterface */
  54 
  55     static {
  56         AccessController.doPrivileged(
  57             new java.security.PrivilegedAction<Void>() {
  58                 public Void run() {
  59                     System.loadLibrary("net");
  60                     return null;
  61                 }
  62             });
  63 
  64         init();
  65         defaultInterface = DefaultInterface.getDefault();
  66         if (defaultInterface != null) {
  67             defaultIndex = defaultInterface.getIndex();
  68         } else {
  69             defaultIndex = 0;
  70         }
  71     }
  72 
  73     /**
  74      * Returns an NetworkInterface object with index set to 0 and name to null.
  75      * Setting such an interface on a MulticastSocket will cause the
  76      * kernel to choose one interface for sending multicast packets.
  77      *
  78      */
  79     NetworkInterface() {
  80     }
  81 
  82     NetworkInterface(String name, int index, InetAddress[] addrs) {
  83         this.name = name;