Package java.net

Examples of java.net.UnknownHostException


    */
   public static CIDR newCIDR(InetAddress baseAddress, int cidrMask) throws UnknownHostException
   {
      if (cidrMask < 0)
      {
         throw new UnknownHostException("Invalid mask length used: " + cidrMask);
      }
      if (baseAddress instanceof Inet4Address)
      {
         if (cidrMask > 32)
         {
            throw new UnknownHostException("Invalid mask length used: " + cidrMask);
         }
         return new CIDR4((Inet4Address) baseAddress, cidrMask);
      }
      // IPv6.
      if (cidrMask > 128)
      {
         throw new UnknownHostException("Invalid mask length used: " + cidrMask);
      }
      return new CIDR6((Inet6Address) baseAddress, cidrMask);
   }
View Full Code Here


   public static CIDR newCIDR(InetAddress baseAddress, String scidrMask) throws UnknownHostException
   {
      int cidrMask = getNetMask(scidrMask);
      if (cidrMask < 0)
      {
         throw new UnknownHostException("Invalid mask length used: " + cidrMask);
      }
      if (baseAddress instanceof Inet4Address)
      {
         if (cidrMask > 32)
         {
            throw new UnknownHostException("Invalid mask length used: " + cidrMask);
         }
         return new CIDR4((Inet4Address) baseAddress, cidrMask);
      }
      cidrMask += 96;
      // IPv6.
      if (cidrMask > 128)
      {
         throw new UnknownHostException("Invalid mask length used: " + cidrMask);
      }
      return new CIDR6((Inet6Address) baseAddress, cidrMask);
   }
View Full Code Here

   public static CIDR newCIDR(String cidr) throws UnknownHostException
   {
      int p = cidr.indexOf("/");
      if (p < 0)
      {
         throw new UnknownHostException("Invalid CIDR notation used: " + cidr);
      }
      String addrString = cidr.substring(0, p);
      String maskString = cidr.substring(p + 1);
      InetAddress addr = addressStringToInet(addrString);
      int mask = 0;
      if (maskString.indexOf(".") < 0)
      {
         mask = parseInt(maskString, -1);
      }
      else
      {
         mask = getNetMask(maskString);
         if (addr instanceof Inet6Address)
         {
            mask += 96;
         }
      }
      if (mask < 0)
      {
         throw new UnknownHostException("Invalid mask length used: " + maskString);
      }
      return newCIDR(addr, mask);
   }
View Full Code Here

    {
      if (e instanceof UnknownHostException)
        throw (UnknownHostException) e;
      e.printStackTrace();
      Log.debug(e);
      throw new UnknownHostException(name);
    }
  }
View Full Code Here

    catch (Exception e)
    {
      if (e instanceof UnknownHostException)
        throw (UnknownHostException) e;
      Log.debug(e);
      throw new UnknownHostException(name);
    }
  }
View Full Code Here

     
      ResponseCode responseCode = answer.getHeaderSection().getResponseCode();
      if (responseCode == ResponseCode.NAME_ERROR)
      {
        _dnsClient.getCache().addNegativeRecord(query, answer);
        throw new UnknownHostException(_record.getName().toString());
      }
      else if (responseCode != ResponseCode.NO_ERROR)
        throw new IOException("Got negative answer: " + answer.getHeaderSection().getResponseCode());
     
      if (answer.getAnswerSection().isEmpty())
        throw new UnknownHostException(_record.getName().toString());
     
      _dnsClient.getCache().addRecordSet(query, answer);
     
      records = getFromCache(record);
    }
View Full Code Here

} while (retry-- > 0);

            dc_list_expiration = now + 1000 * 60 * 15; /* 15 min */
        }

        throw new UnknownHostException(
                "Failed to negotiate with a suitable domain controller for " + DOMAIN );
    }
View Full Code Here

                while( sem.count > 0 && q1x.ans == null && q20.ans == null ) {
                    sem.wait();
                }
            }
        } catch( InterruptedException ie ) {
            throw new UnknownHostException( name );
        }
        if( q1x.ans != null ) {
            return q1x.ans;
        } else if( q20.ans != null ) {
            return q20.ans;
View Full Code Here

                                        throws UnknownHostException {
        Object addr;
        int i;

        if( hostname == null || hostname.length() == 0 ) {
            throw new UnknownHostException();
        }

        if( isDotQuadIP( hostname )) {
            UniAddress[] addrs = new UniAddress[1];
            addrs[0] = new UniAddress( NbtAddress.getByName( hostname ));
            return addrs;
        }

        for( i = 0; i < resolveOrder.length; i++ ) {
            try {
                switch( resolveOrder[i] ) {
                    case RESOLVER_LMHOSTS:
                        if(( addr = Lmhosts.getByName( hostname )) == null ) {
                            continue;
                        }
                        break;
                    case RESOLVER_WINS:
                        if( hostname == NbtAddress.MASTER_BROWSER_NAME ||
                                                    hostname.length() > 15 ) {
                                                    // invalid netbios name
                            continue;
                        }
                        if( possibleNTDomainOrWorkgroup ) {
                            addr = lookupServerOrWorkgroup( hostname, NbtAddress.getWINSAddress() );
                        } else {
                            addr = NbtAddress.getByName( hostname, 0x20, null, NbtAddress.getWINSAddress() );
                        }
                        break;
                    case RESOLVER_BCAST:
                        if( hostname.length() > 15 ) {
                            // invalid netbios name
                            continue;
                        }
                        if( possibleNTDomainOrWorkgroup ) {
                            addr = lookupServerOrWorkgroup( hostname, baddr );
                        } else {
                            addr = NbtAddress.getByName( hostname, 0x20, null, baddr );
                        }
                        break;
                    case RESOLVER_DNS:
                        if( isAllDigits( hostname )) {
                            throw new UnknownHostException( hostname );
                        }
                        InetAddress[] iaddrs = InetAddress.getAllByName( hostname );
                        UniAddress[] addrs = new UniAddress[iaddrs.length];
                        for (int ii = 0; ii < iaddrs.length; ii++) {
                            addrs[ii] = new UniAddress(iaddrs[ii]);
                        }
                        return addrs; // Success
                    default:
                        throw new UnknownHostException( hostname );
                }
                UniAddress[] addrs = new UniAddress[1];
                addrs[0] = new UniAddress( addr );
                return addrs; // Success
            } catch( IOException ioe ) {
                // Failure
            }
        }
        throw new UnknownHostException( hostname );
    }
View Full Code Here

            try {
                ans = NbtAddress.getByName( host, type, scope, svr );
            } catch( UnknownHostException uhe ) {
                this.uhe = uhe;
            } catch( Exception ex ) {
                this.uhe = new UnknownHostException( ex.getMessage() );
            } finally {
                synchronized( sem ) {
                    sem.count--;
                    sem.notify();
                }
View Full Code Here

TOP

Related Classes of java.net.UnknownHostException

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.