Class DNSmessage

java.lang.Object
   |
   +----DNSmessage

public class DNSmessage
extends Object
DNSmessage is used for sending and receiving queries from domain name servers.
Version:
2.0, 30 Oct 1998
Author:
Ketsle Alexander

Variable Index

o QT_A
A query of type A
o QT_CNAME
A query of type CNAME
o QT_HINFO
A query of type HINFO
o QT_MX
A query of type MX
o QT_NS
A query of type NS
o QT_PTR
A query of type PTR
o QT_TXT
A query of type TXT

Constructor Index

o DNSmessage(boolean)
Constructs a new instance of DNSmessage class.
o DNSmessage(boolean, int)
Constructs a new instance of DNSmessage class with a specified SO_TIMEOUT on client socket.

Method Index

o getAllAnswers()
Returns a resource data of answers, authority and additional information portions of DNS reply message.
o getAllDomainNames()
Returns a domain name data of answers, authority and additional information portions of DNS reply message.
o getAnswersTotal()
Returns total number of answers, authority and additional info records in DNS reply message.
o getMXPreferences()
Returns values of MX preferences in DNS reply to MX query message.
o getNumberOfAdditionalRec()
Returns a number of additional records in DNS reply message.
o getNumberOfAnswers()
Returns a number of answers in DNS reply message.
o getNumberOfAuthorityRec()
Returns a number of authority records in DNS reply message.
o getReturnCode()
To get a return code (rcode field) of a reply message.
o printMessage(Object)
Prints a contents of a DNS reply datagram
o receiveMessage()
Receives a reply on specified nameserver.
o sendMessage(String)
Sends a query to specified nameserver.
o setMessage(String, int)
Prepares a datagram for query.

Variables

o QT_A
 public static int QT_A
A query of type A

 

o QT_NS
 public static int QT_NS
A query of type NS

 

o QT_CNAME
 public static int QT_CNAME
A query of type CNAME

 

o QT_PTR
 public static int QT_PTR
A query of type PTR

 

o QT_HINFO
 public static int QT_HINFO
A query of type HINFO

 

o QT_MX
 public static int QT_MX
A query of type MX

 

o QT_TXT
 public static int QT_TXT
A query of type TXT

 

Constructors

o DNSmessage
 public DNSmessage(boolean deb)
Constructs a new instance of DNSmessage class.
Parameters:
deb - turn on debug output to stdout
o DNSmessage
 public DNSmessage(boolean deb,
                   int sotimeout)
Constructs a new instance of DNSmessage class with a specified SO_TIMEOUT on client socket.
Parameters:
deb - turn on debug output to stdout
sotimeout - set a SO_TIMEOUT in milliseconds on client socket

Methods

o setMessage
 public int setMessage(String query_1,
                       int qtype)
Prepares a datagram for query.
Parameters:
query_1 - a content of query, e. g. ns.sun.com
qtype - a type of query - QT_A, QT_PTR, QT_MX, QT_HINFO or QT_TXT.
Returns:
a total length of a query datagram
o printMessage
 public int printMessage(Object ta)
Prints a contents of a DNS reply datagram
Parameters:
ta - an output destination, the instance of one of the following classes: TextArea, FileOutputStream or PrintStream.
o sendMessage
 public int sendMessage(String nameserver)
Sends a query to specified nameserver. A query must already been prepared by setMessage().
Parameters:
nameserver - an IP or hostname of nameserver
Returns:
-1 on UnknownHostException,-2 on IOException, 0 otherwise
See Also:
setMessage
o receiveMessage
 public int receiveMessage()
Receives a reply on specified nameserver. When 0 return, contents of a DNSmessage class are set to reply information
Parameters:
nameserver - an IP or hostname of nameserver
Returns:
-1 on timeout waiting for reply, -2 on IOException, an id of reply, when it is different from a id of query, 0 otherwise
o getReturnCode
 public int getReturnCode()
To get a return code (rcode field) of a reply message.
Returns:
2 server failed(SERVFAIL), 3 name error, 0no error
o getAllAnswers
 public String[] getAllAnswers()
Returns a resource data of answers, authority and additional information portions of DNS reply message.
Returns:
a String array of resource data
See Also:
getAnswersTotal
o getAllDomainNames
 public String[] getAllDomainNames()
Returns a domain name data of answers, authority and additional information portions of DNS reply message.
Returns:
a String array of domain name data
See Also:
getAnswersTotal
o getMXPreferences
 public int[] getMXPreferences()
Returns values of MX preferences in DNS reply to MX query message.
Returns:
total number of records
o getAnswersTotal
 public int getAnswersTotal()
Returns total number of answers, authority and additional info records in DNS reply message.
Returns:
total number of records
o getNumberOfAnswers
 public int getNumberOfAnswers()
Returns a number of answers in DNS reply message.
Returns:
number of answers
o getNumberOfAuthorityRec
 public int getNumberOfAuthorityRec()
Returns a number of authority records in DNS reply message.
Returns:
number of authority records
o getNumberOfAdditionalRec
 public int getNumberOfAdditionalRec()
Returns a number of additional records in DNS reply message.
Returns:
number of additional records