Package java.net

Examples of java.net.UnknownHostException


            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


                try {
                    send( request, response, RETRY_TIMEOUT );
                } catch( IOException ioe ) {
                    if( DebugFile.trace )
                        new ErrorHandler (ioe);
                    throw new UnknownHostException( name.name );
                }

                if( response.received && response.resultCode == 0 ) {
                    response.addrEntry.hostName.srcHashCode = addr.hashCode();
                    return response.addrEntry;
                }
            } while( --n > 0 && request.isBroadcast );

            throw new UnknownHostException( name.name );
        }

        /* If a target address to query was not specified explicitly
         * with the addr parameter we fall into this resolveOrder routine.
         */

        for( int i = 0; i < resolveOrder.length; i++ ) {
            try {
                switch( resolveOrder[i] ) {
                    case RESOLVER_LMHOSTS:
                        NbtAddress ans = Lmhosts.getByName( name );
                        if( ans != null ) {
                            ans.hostName.srcHashCode = 0; // just has to be different
                                                          // from other methods
                            return ans;
                        }
                        break;
                    case RESOLVER_WINS:
                    case RESOLVER_BCAST:
                        if( resolveOrder[i] == RESOLVER_WINS &&
                                name.name != NbtAddress.MASTER_BROWSER_NAME &&
                                name.hexCode != 0x1d ) {
                            request.addr = NbtAddress.getWINSAddress();
                            request.isBroadcast = false;
                        } else {
                            request.addr = baddr;
                            request.isBroadcast = true;
                        }

                        n = RETRY_COUNT;
                        while( n-- > 0 ) {
                            try {
                                send( request, response, RETRY_TIMEOUT );
                            } catch( IOException ioe ) {
                                if( DebugFile.trace )
                                    new ErrorHandler(ioe);
                                throw new UnknownHostException( name.name );
                            }
                            if( response.received && response.resultCode == 0 ) {

/* Before we return, in anticipation of this address being cached we must
* augment the addresses name's hashCode to distinguish those resolved by
* Lmhosts, WINS, or BCAST. Otherwise a failed query from say WINS would
* get pulled out of the cache for a BCAST on the same name.
*/
                                response.addrEntry.hostName.srcHashCode =
                                                        request.addr.hashCode();
                                return response.addrEntry;
                            } else if( resolveOrder[i] == RESOLVER_WINS ) {
                                /* If WINS reports negative, no point in retry
                                 */
                                break;
                            }
                        }
                        break;
                }
            } catch( IOException ioe ) {
            }
        }
        throw new UnknownHostException( name.name );
    }
View Full Code Here

            try {
                send( request, response, RETRY_TIMEOUT );
            } catch( IOException ioe ) {
                if( DebugFile.trace )
                    new ErrorHandler(ioe);
                throw new UnknownHostException( addr.toString() );
            }
            if( response.received && response.resultCode == 0 ) {

        /* For name queries resolved by different sources (e.g. WINS,
         * BCAST, Node Status) we need to augment the hashcode generated
         * for the addresses hostname or failed lookups for one type will
         * be cached and cause other types to fail even though they may
         * not be the authority for the name. For example, if a WINS lookup
         * for FOO fails and caches unknownAddress for FOO, a subsequent
         * lookup for FOO using BCAST should not fail because of that
         * name cached from WINS.
         *
         * So, here we apply the source addresses hashCode to each name to
         * make them specific to who resolved the name.
         */

                srcHashCode = request.addr.hashCode();
                for( int i = 0; i < response.addressArray.length; i++ ) {
                    response.addressArray[i].hostName.srcHashCode = srcHashCode;
                }
                return response.addressArray;
            }
        }
        throw new UnknownHostException( addr.hostName.name );
    }
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

        bytes.length);

    try {
      InetAddress ipv4 = InetAddress.getByAddress(bytes);
      if (!(ipv4 instanceof Inet4Address)) {
        throw new UnknownHostException(
            String.format("'%s' is not an IPv4 address.",
                          ipv4.getHostAddress()));
      }

      return (Inet4Address) ipv4;
View Full Code Here

            if (fse.getCause().getClass().getName().equals("jcifs.smb.SmbAuthException")) {
                throw new DAVAuthenticationRequiredException(getMountString());
            }
            if (fse.getCause() != null && fse.getCause() instanceof SmbException && ((SmbException) fse.getCause()).getRootCause() != null
                            && "Connection timeout".equals(((SmbException) fse.getCause()).getRootCause().getMessage())) {
                throw new UnknownHostException(uri.getHost());
            }
            if(log.isDebugEnabled())
                log.debug("File system exception! ", fse);
            throw fse;
        }
View Full Code Here

        if (NAME_CACHE_MISS.containsKey(host)) {
            cacheMiss_Hit++;
            return null;
        }
        cacheMiss_Miss++;
        throw new UnknownHostException("host not in cache");
    }
View Full Code Here

        principal   = certificate.getSubjectDN();
        DN          = String.valueOf(principal);
        start       = DN.indexOf("CN=");

        if (start < 0) {
            throw new UnknownHostException(
                Error.getMessage(ErrorCode.M_SERVER_SECURE_VERIFY_1));
        }

        start += 3;
        end   = DN.indexOf(',', start);
        CN    = DN.substring(start, (end > -1) ? end
                                               : DN.length());

        if (CN.length() < 1) {
            throw new UnknownHostException(
                Error.getMessage(ErrorCode.M_SERVER_SECURE_VERIFY_2));
        }

        if (!CN.equalsIgnoreCase(host)) {

            // TLS_HOSTNAME_MISMATCH
            throw new UnknownHostException(
                Error.getMessage(
                    ErrorCode.M_SERVER_SECURE_VERIFY_3, 0,
                    new Object[] {
                CN, host
            }));
View Full Code Here

                } else {
                    messageID = ErrorCode.M_SERVER_OPEN_SERVER_SOCKET_2;
                    messageParameters = new Object[]{ address };
                }

                throw new UnknownHostException(Error.getMessage(messageID, 0,
                        messageParameters));
            }
        }

        /*
 
View Full Code Here

   {
      byte[] a = new byte[16];
      byte[] b = addr.toByteArray();
      if (b.length > 16 && !(b.length == 17 && b[0] == 0))
      {
         throw new UnknownHostException("invalid IPv6 address (too big)");
      }
      if (b.length == 16)
      {
         return InetAddress.getByAddress(b);
      }
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.