Package java.net

Examples of java.net.NetworkInterface


      try{
        Enumeration   nis = NetworkInterface.getNetworkInterfaces();

        while( nis.hasMoreElements()){
         
          NetworkInterface   ni = (NetworkInterface)nis.nextElement();
           
          Enumeration addresses = ni.getInetAddresses();
         
          while( addresses.hasMoreElements()){
           
            InetAddress address = (InetAddress)addresses.nextElement();
           
View Full Code Here


        Enumeration<NetworkInterface> nifs = NetworkInterface
                .getNetworkInterfaces();

        List<String> hostIps = new ArrayList<String>();
        while (nifs.hasMoreElements()) {
            NetworkInterface nif = nifs.nextElement();
            Enumeration<InetAddress> ips = nif.getInetAddresses();

            while (ips.hasMoreElements()) {
                InetAddress ip = ips.nextElement();
                if (ip instanceof java.net.Inet4Address) {
                    hostIps.add(ip.getHostAddress());
View Full Code Here

    public static InetAddress findNonLocalhostIp() throws Exception {
        Enumeration<NetworkInterface> nifs = NetworkInterface
                .getNetworkInterfaces();

        while (nifs.hasMoreElements()) {
            NetworkInterface nif = nifs.nextElement();
            Enumeration<InetAddress> ips = nif.getInetAddresses();

            while (ips.hasMoreElements()) {
                InetAddress ip = ips.nextElement();
                if (ip instanceof java.net.Inet4Address
                        && !ip.isLoopbackAddress()) {
View Full Code Here

 
   
    List<String> list = new ArrayList<String>();
   
    while (e.hasMoreElements()) {
      NetworkInterface n = e.nextElement();
     
      list.add(n.getDisplayName());
    }
   
    System.out.println(list);
   
    return list.toArray(new String[list.size()]);
View Full Code Here

    this.rawLinkType = PcapDLT.asPcap(dlt).intValue();
  }

  protected void initFromJavaNetNetworkInterface(String device)
      throws SocketException {
    NetworkInterface netint = NetworkInterface.getByName(device);

    name = netint.getName();
    displayName = netint.getDisplayName();
    timezome = TimeZone.getDefault().getRawOffset();

    Enumeration<InetAddress> e = netint.getInetAddresses();
    while (e.hasMoreElements()) {
      addresses.add(new IpAddress(e.nextElement().getAddress()));
    }

  }
View Full Code Here

   private static InetAddress findLoopbackAddress() throws SocketException
   {
      Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
      while (ifaces.hasMoreElements())
      {
         NetworkInterface iface = ifaces.nextElement();
         Enumeration<InetAddress> addrs = iface.getInetAddresses();
         while (addrs.hasMoreElements())
         {
            InetAddress addr = addrs.nextElement();
            if (addr.isLoopbackAddress())
            {
View Full Code Here

        if (hostname.equals("")) {
            try {
                Enumeration e = NetworkInterface.getNetworkInterfaces();

                while (e.hasMoreElements() && hostname == null) {
                    NetworkInterface netface = (NetworkInterface) e.nextElement();
                    Enumeration e2 = netface.getInetAddresses();
                    while (e2.hasMoreElements() && hostname == null) {
                        InetAddress ip = (InetAddress) e2.nextElement();
                        if (!ip.getCanonicalHostName().equals("localhost")
                                        && !ip.getCanonicalHostName().equals("localhost.localdomain")) {
                            hostname = ip.getCanonicalHostName();
View Full Code Here

            // TODO make this localised
            l.add(new LabelValueBean("All Interfaces",
                "0.0.0.0"));           
            for(Enumeration e = NetworkInterface.getNetworkInterfaces();
                e.hasMoreElements(); ) {
                NetworkInterface ni = (NetworkInterface)e.nextElement();
                for(Enumeration e2 = ni.getInetAddresses(); e2.hasMoreElements(); ) {
                    InetAddress addr = (InetAddress)e2.nextElement();
                    l.add(new LabelValueBean(addr.getHostAddress(),
                        addr.getHostAddress()));
                }               
            }
View Full Code Here

        Enumeration e = null;
        try {
            List niList = new ArrayList();
            e = NetworkInterface.getNetworkInterfaces();
            while (e.hasMoreElements()) {
                NetworkInterface netface = (NetworkInterface) e.nextElement();
                Enumeration e2 = netface.getInetAddresses();
                while (e2.hasMoreElements()) {
                    InetAddress ip = (InetAddress) e2.nextElement();
                    niList.add(netface.getName() + "=" + ip.toString());
                }
            }
            return niList;
        } catch (SocketException e1) {
            return new ArrayList();
View Full Code Here

              if(getTunnelType() == TransportType.REMOTE_TUNNEL_ID) {
                if(!sourceInterface.trim().equals("0.0.0.0") &&
                  !sourceInterface.trim().equals("127.0.0.2"))
                  try {
                    InetAddress addr = InetAddress.getByName(sourceInterface);
                    NetworkInterface nif = NetworkInterface.getByInetAddress(addr);
                    if(nif == null) {
                      throw new Exception();
                    }
                  }
                  catch(Exception e) {             
View Full Code Here

TOP

Related Classes of java.net.NetworkInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.