public InetAddress [ ] lookupAllHostAddr ( String host ) throws UnknownHostException { Name name = null ; try { name = new Name ( host ) ; } catch ( TextParseException e ) { throw new UnknownHostException ( host ) ; } Record [ ] records = null ; if ( preferV6 ) records = new Lookup ( name , Type . AAAA ) . run ( ) ; if ( records == null ) records = new Lookup ( name , Type . A ) . run ( ) ; if ( records == null && ! preferV6 ) records = new Lookup ( name , Type . AAAA ) . run ( ) ; if ( records == null ) throw new UnknownHostException ( host ) ; InetAddress [ ] array = new InetAddress [ records . length ] ; for ( int i = 0 ; i < records . length ; i ++ ) { Record record = records [ i ] ; if ( records [ i ] instanceof ARecord ) { ARecord a = ( ARecord ) records [ i ] ; array [ i ] = a . getAddress ( ) ; } else { AAAARecord aaaa = ( AAAARecord ) records [ i ] ; array [ i ] = aaaa . getAddress ( ) ; } } return array ; }
Performs a forward DNS lookup for the host name .