Package javax.jmdns.impl
Class DNSOutgoing
- java.lang.Object
-
- javax.jmdns.impl.DNSMessage
-
- javax.jmdns.impl.DNSOutgoing
-
public final class DNSOutgoing extends DNSMessage
An outgoing DNS message.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDNSOutgoing.MessageOutputStream
-
Field Summary
Fields Modifier and Type Field Description private DNSOutgoing.MessageOutputStream_additionalsAnswersBytesprivate DNSOutgoing.MessageOutputStream_answersBytesprivate DNSOutgoing.MessageOutputStream_authoritativeAnswersBytesprivate java.net.InetSocketAddress_destinationprivate int_maxUDPPayload(package private) java.util.Map<java.lang.String,java.lang.Integer>_namesprivate DNSOutgoing.MessageOutputStream_questionsBytesprivate static intHEADER_SIZEstatic booleanUSE_DOMAIN_NAME_COMPRESSIONThis can be used to turn off domain name compression.-
Fields inherited from class javax.jmdns.impl.DNSMessage
_additionals, _answers, _authoritativeAnswers, _multicast, _questions, MULTICAST, UNICAST
-
-
Constructor Summary
Constructors Constructor Description DNSOutgoing(int flags)Create an outgoing multicast query or response.DNSOutgoing(int flags, boolean multicast)Create an outgoing query or response.DNSOutgoing(int flags, boolean multicast, int senderUDPPayload)Create an outgoing query or response.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAdditionalAnswer(DNSIncoming in, DNSRecord rec)Add an additional answer to the record.voidaddAnswer(DNSIncoming in, DNSRecord rec)Add an answer if it is not suppressed.voidaddAnswer(DNSRecord rec, long now)Add an answer to the message.voidaddAuthorativeAnswer(DNSRecord rec)Add an authoritative answer to the message.voidaddQuestion(DNSQuestion rec)Add a question to the message.intavailableSpace()Return the number of byte available in the message.byte[]data()Builds the final message buffer to be send and returns it.java.net.InetSocketAddressgetDestination()Get the forced destination address if a specific one was set.intgetMaxUDPPayload()(package private) java.lang.Stringprint(boolean dump)Debugging.voidsetDestination(java.net.InetSocketAddress destination)Force a specific destination address if packet is sent.java.lang.StringtoString()-
Methods inherited from class javax.jmdns.impl.DNSMessage
getAdditionals, getAllAnswers, getAnswers, getAuthorities, getFlags, getId, getNumberOfAdditionals, getNumberOfAnswers, getNumberOfAuthorities, getNumberOfQuestions, getOperationCode, getQuestions, isAuthoritativeAnswer, isEmpty, isMulticast, isQuery, isResponse, isTruncated, isValidResponseCode, print, print, setFlags, setId
-
-
-
-
Field Detail
-
USE_DOMAIN_NAME_COMPRESSION
public static boolean USE_DOMAIN_NAME_COMPRESSION
This can be used to turn off domain name compression. This was helpful for tracking problems interacting with other mdns implementations.
-
_names
java.util.Map<java.lang.String,java.lang.Integer> _names
-
_maxUDPPayload
private int _maxUDPPayload
-
_questionsBytes
private final DNSOutgoing.MessageOutputStream _questionsBytes
-
_answersBytes
private final DNSOutgoing.MessageOutputStream _answersBytes
-
_authoritativeAnswersBytes
private final DNSOutgoing.MessageOutputStream _authoritativeAnswersBytes
-
_additionalsAnswersBytes
private final DNSOutgoing.MessageOutputStream _additionalsAnswersBytes
-
HEADER_SIZE
private static final int HEADER_SIZE
- See Also:
- Constant Field Values
-
_destination
private java.net.InetSocketAddress _destination
-
-
Constructor Detail
-
DNSOutgoing
public DNSOutgoing(int flags)
Create an outgoing multicast query or response.- Parameters:
flags-
-
DNSOutgoing
public DNSOutgoing(int flags, boolean multicast)Create an outgoing query or response.- Parameters:
flags-multicast-
-
DNSOutgoing
public DNSOutgoing(int flags, boolean multicast, int senderUDPPayload)Create an outgoing query or response.- Parameters:
flags-multicast-senderUDPPayload- The sender's UDP payload size is the number of bytes of the largest UDP payload that can be reassembled and delivered in the sender's network stack.
-
-
Method Detail
-
getDestination
public java.net.InetSocketAddress getDestination()
Get the forced destination address if a specific one was set.- Returns:
- a forced destination address or null if no address is forced.
-
setDestination
public void setDestination(java.net.InetSocketAddress destination)
Force a specific destination address if packet is sent.- Parameters:
destination- Set a destination address a packet should be sent to (instead the default one). You could use null to unset the forced destination.
-
availableSpace
public int availableSpace()
Return the number of byte available in the message.- Returns:
- available space
-
addQuestion
public void addQuestion(DNSQuestion rec) throws java.io.IOException
Add a question to the message.- Parameters:
rec-- Throws:
java.io.IOException
-
addAnswer
public void addAnswer(DNSIncoming in, DNSRecord rec) throws java.io.IOException
Add an answer if it is not suppressed.- Parameters:
in-rec-- Throws:
java.io.IOException
-
addAnswer
public void addAnswer(DNSRecord rec, long now) throws java.io.IOException
Add an answer to the message.- Parameters:
rec-now-- Throws:
java.io.IOException
-
addAuthorativeAnswer
public void addAuthorativeAnswer(DNSRecord rec) throws java.io.IOException
Add an authoritative answer to the message.- Parameters:
rec-- Throws:
java.io.IOException
-
addAdditionalAnswer
public void addAdditionalAnswer(DNSIncoming in, DNSRecord rec) throws java.io.IOException
Add an additional answer to the record. Omit if there is no room.- Parameters:
in-rec-- Throws:
java.io.IOException
-
data
public byte[] data()
Builds the final message buffer to be send and returns it.- Returns:
- bytes to send.
-
print
java.lang.String print(boolean dump)
Debugging.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getMaxUDPPayload
public int getMaxUDPPayload()
- Returns:
- the maxUDPPayload
-
-