com.internationalnetwork.net
Class QueryDNS

Object
  extended by com.internationalnetwork.net.QueryDNS

public class QueryDNS
extends Object

QueryDNS is a very flexible class that was converted from a version that was written many years earlier in pure 100% assembler and compiled into NLM form which was used on Novell's NetWare Operating System. The flexibility that was developed into it is now much simpler to implement because Java handles different data types so that class (library) developers don't have to worry about such details, albeit at the expense of having more constructors and methods, which not only is a trade-off that actually results in better performance since fewer conditions must be checked, but also results in better system stability since incorrect data types cannot be passed through by mistake by those who don't pay as close attention to the details as they should.


Field Summary
static String VERSION
          Version number of this Package (read-only).
 
Method Summary
static RR[] lookup(String nameServer, int port, int nsTimeout, int nsRetries, boolean authoritative, boolean recursion, String idn, int rrClass, int... rrType)
          Send a DNS query to a specific DNS server, and returns the results as an RR[] array containing the record types specified.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
Version number of this Package (read-only).

See Also:
Constant Field Values
Method Detail

lookup

public static RR[] lookup(String nameServer,
                          int port,
                          int nsTimeout,
                          int nsRetries,
                          boolean authoritative,
                          boolean recursion,
                          String idn,
                          int rrClass,
                          int... rrType)
                   throws javax.naming.NamingException,
                          java.net.SocketTimeoutException
Send a DNS query to a specific DNS server, and returns the results as an RR[] array containing the record types specified.

Parameters:
nameServer - IP address or hostname of the specific DNS server to send the query to
port - UDP/TCP port number (normally 53)
nsTimeout - Number of milliseconds to wait for a reply to the query before aborting the query
nsRetries - Number of times to re-send the query when a timeout is encountered
authoritative - Requires that the specified name server must be an official authority for the zone being queried (normally set to "false" for most queries)
recursion - Allow the specified name server to recursively query other DNS servers (such as root servers) for the answer (normally set to "true" for most queries)
idn - The Internet Domain Name to use in the query
rrClass - Normally set to 1 for most queries (see the _CLASS constants in com.internationalnetwork.net.RR for more details)
rrType - One or more DNS types to include in the query
Returns:
RR[] array containing all records, in no particular order (although they are usually grouped together, it's important not to rely on this ordering because no effort is made in this method to sort them and a future version of Java could cause this behaviour to change in the future)
Throws:
javax.naming.NamingException - This exception really needs to be caught because communications problems can occur at any time
java.net.SocketTimeoutException - If the timeout period elapses, this exception will be thrown (and should also be caught for the same reason that javax.naming.NamingException should always be caught)