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

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

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

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

QT_A
public static int QT_A
-
A query of type A
QT_NS
public static int QT_NS
-
A query of type NS
QT_CNAME
public static int QT_CNAME
-
A query of type CNAME
QT_PTR
public static int QT_PTR
-
A query of type PTR
QT_HINFO
public static int QT_HINFO
-
A query of type HINFO
QT_MX
public static int QT_MX
-
A query of type MX
QT_TXT
public static int QT_TXT
-
A query of type TXT

DNSmessage
public DNSmessage(boolean deb)
-
Constructs a new instance of DNSmessage class.
-
Parameters:
-
deb - turn on debug output to stdout
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

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
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.
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
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
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
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
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
getMXPreferences
public int[] getMXPreferences()
-
Returns values of MX preferences in DNS reply to MX query message.
-
Returns:
-
total number of records
getAnswersTotal
public int getAnswersTotal()
-
Returns total number of answers, authority and additional info records
in DNS reply message.
-
Returns:
-
total number of records
getNumberOfAnswers
public int getNumberOfAnswers()
-
Returns a number of answers in DNS reply message.
-
Returns:
-
number of answers
getNumberOfAuthorityRec
public int getNumberOfAuthorityRec()
-
Returns a number of authority records in DNS reply message.
-
Returns:
-
number of authority records
getNumberOfAdditionalRec
public int getNumberOfAdditionalRec()
-
Returns a number of additional records in DNS reply message.
-
Returns:
-
number of additional records