Class JmDNSImpl
- All Implemented Interfaces:
Closeable
,AutoCloseable
,DNSStatefulObject
,DNSTaskStarter
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
private static class
Instances of ServiceCollector are used internally to speed up the performance of methodlist(type)
.static class
This is used to store type entries.protected class
Shutdown operations.Nested classes/interfaces inherited from class javax.jmdns.JmDNS
JmDNS.Delegate
Nested classes/interfaces inherited from interface javax.jmdns.impl.DNSStatefulObject
DNSStatefulObject.DefaultImplementation, DNSStatefulObject.DNSStatefulObjectSemaphore
Nested classes/interfaces inherited from interface javax.jmdns.impl.DNSTaskStarter
DNSTaskStarter.DNSTaskStarterImpl, DNSTaskStarter.Factory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DNSCache
Cache for DNSEntry's.private JmDNS.Delegate
private final ExecutorService
private InetAddress
This is the multicast group, we are listening to for multicast DNS messages.private Thread
private final ReentrantLock
This lock is used to coordinate processing of incoming and outgoing messages.private long
Last throttle increment.private final List
<DNSListener> Holds instances of JmDNS.DNSListener.private HostInfo
Handle on the local hostprivate final String
private DNSIncoming
If an incoming package which needs an answer is truncated, we store it here.private static final Random
The source for random values.private final Object
private final ConcurrentMap
<String, JmDNSImpl.ServiceCollector> This hashtable is used to maintain a list of service types being collected by this JmDNS instance.(package private) final ConcurrentMap
<String, List<ListenerStatus.ServiceListenerStatus>> Holds instances of ServiceListener's.private final ConcurrentMap
<String, ServiceInfo> This hashtable holds the services that have been registered.private final ConcurrentMap
<String, JmDNSImpl.ServiceTypeEntry> This hashtable holds the service types that have been registered or that have been received in an incoming datagram.
Keys are instances of String which hold an all lower-case version of the fully qualified service type.
Values hold the fully qualified service type.protected Thread
This is the shutdown hook, we registered with the java runtime.private MulticastSocket
This is our multicast socket.protected final long
private int
Throttle count.private final Set
<ListenerStatus.ServiceTypeListenerStatus> Holds instances of ServiceTypeListener's.private static org.slf4j.Logger
-
Constructor Summary
ConstructorsConstructorDescriptionJmDNSImpl
(InetAddress address, String name) Create an instance of JmDNS and bind it to a specific network interface given its IP-address.JmDNSImpl
(InetAddress address, String name, long threadSleepDurationMs) Create an instance of JmDNS and bind it to a specific network interface given its IP-address. -
Method Summary
Modifier and TypeMethodDescription(package private) void
addAnswer
(DNSIncoming in, InetAddress addr, int port, DNSOutgoing out, DNSRecord rec) Add an answer to a question.void
addListener
(DNSListener listener, DNSQuestion question) Add a listener for a question.void
addServiceListener
(String type, ServiceListener listener) Listen for services of a given type.private void
addServiceListener
(String type, ServiceListener listener, boolean synch) void
addServiceTypeListener
(ServiceTypeListener listener) Listen for service types.boolean
advanceState
(DNSTask task) Sets the state and notifies all objects that wait on the ServiceInfo.aRecordsLast
(List<DNSRecord> allAnswers) In case the a record is received before the srv record the ip address would not be set.void
associateWithTask
(DNSTask task, DNSState state) Sets the task associated with this Object.boolean
Sets the state and notifies all objects that wait on the ServiceInfo.void
Cancel the state task timervoid
Cancel the generals task timervoid
Checks the cache of expired records and removes them.void
close()
private void
boolean
Sets the state and notifies all objects that wait on the ServiceInfo.private void
This method disposes all ServiceCollector instances which have been created by calls to methodlist(type)
.getCache()
Return the DNSCache associated with the cache variableReturns the instance delegategetDns()
Returns the DNS associated with this object.getGroup()
Return the HostName associated with this JmDNS instance.Return the address of the interface to which this instance of JmDNS is bound.Deprecated.long
Returns the local host infogetName()
Return the name of the JmDNS instance.static Random
getServiceInfo
(String type, String name) Get service information.getServiceInfo
(String type, String name, boolean persistent) Get service information.getServiceInfo
(String type, String name, boolean persistent, long timeout) Get service information.getServiceInfo
(String type, String name, long timeout) Get service information.(package private) ServiceInfoImpl
getServiceInfoFromCache
(String type, String name, String subtype, boolean persistent) int
(package private) void
handleQuery
(DNSIncoming in, InetAddress addr, int port) Handle an incoming query.(package private) void
handleRecord
(DNSRecord record, long now) (package private) void
Handle an incoming response.(package private) void
void
ioLock()
void
ioUnlock()
boolean
Returns true, if this is an announced state.boolean
Returns true, if this is an announcing state.boolean
isAssociatedWithTask
(DNSTask task, DNSState state) Checks if this object is associated with the task and in the same state.boolean
Returns true, if this is a canceled state.boolean
Returns true, if this is a canceling state.boolean
isClosed()
Returns true, if this is a closed state.boolean
Returns true, if this is a closing state.private boolean
isOlderThanOneSecond
(DNSRecord dnsRecord, long timeToCompare) boolean
Returns true, if this is a probing state.Returns a list of service infos of the specified type.Returns a list of service infos of the specified type.Map
<String, ServiceInfo[]> listBySubtype
(String type) Returns a list of service infos of the specified type sorted by subtype.Map
<String, ServiceInfo[]> listBySubtype
(String type, long timeout) Returns a list of service infos of the specified type sorted by subtype.static void
Main method to display API information if run from java -jarprivate boolean
Generate a possibly unique name for a service using the information we have in the cache.private void
openMulticastSocket
(HostInfo hostInfo) void
Deprecated.void
Purge the state task timervoid
Purge the general task timervoid
recover()
Recover jmDNS when there is an error.boolean
Sets the state and notifies all objects that wait on the ServiceInfo.void
registerService
(ServiceInfo infoAbstract) Register a service.boolean
registerServiceType
(String type) Register a service type.void
Remove the association of the task with this Object.void
removeListener
(DNSListener listener) Remove a listener from all outstanding questions.private void
void
removeServiceListener
(String type, ServiceListener listener) Remove listener for services of a given type.void
removeServiceTypeListener
(ServiceTypeListener listener) Remove listener for service types.void
renewServiceCollector
(String type) Renew a service when the record become stale.void
requestServiceInfo
(String type, String name) Request service information.void
requestServiceInfo
(String type, String name, boolean persistent) Request service information.void
requestServiceInfo
(String type, String name, boolean persistent, long timeout) Request service information.void
requestServiceInfo
(String type, String name, long timeout) Request service information.(package private) ServiceInfoImpl
resolveServiceInfo
(String type, String name, String subtype, boolean persistent) void
boolean
Sets the state and notifies all objects that wait on the ServiceInfo.void
send
(DNSOutgoing out) Send an outgoing multicast DNS message.setDelegate
(JmDNS.Delegate delegate) Sets the instance delegatevoid
setLastThrottleIncrement
(long lastThrottleIncrement) (package private) void
setLocalHost
(HostInfo localHost) void
setPlannedAnswer
(DNSIncoming plannedAnswer) void
setThrottle
(int throttle) private void
start
(Collection<? extends ServiceInfo> serviceInfos) void
Start a new announcer taskvoid
Start a new canceler taskvoid
Start a new prober taskvoid
Start a new reaper task.void
Start a new renewer taskvoid
startResponder
(DNSIncoming in, InetAddress addr, int port) Start a new responder taskvoid
Start a new service info resolver taskvoid
startServiceResolver
(String type) Start a new service resolver taskvoid
Start a new service type resolver tasktoString()
(package private) static String
toUnqualifiedName
(String type, String qualifiedName) void
Unregister all services.void
unregisterService
(ServiceInfo infoAbstract) Unregister a service.void
updateRecord
(long now, DNSRecord rec, JmDNSImpl.Operation operation) Notify all listeners that a record was updated.boolean
waitForAnnounced
(long timeout) Waits for the object to be announced.boolean
waitForCanceled
(long timeout) Waits for the object to be canceled.private void
waitForInfoData
(ServiceInfo info, long timeout)
-
Field Details
-
logger
private static org.slf4j.Logger logger -
_group
This is the multicast group, we are listening to for multicast DNS messages. -
_socket
This is our multicast socket. -
_listeners
Holds instances of JmDNS.DNSListener. Must by a synchronized collection, because it is updated from concurrent threads. -
_serviceListeners
Holds instances of ServiceListener's. Keys are Strings holding a fully qualified service type. Values are LinkedList's of ServiceListener's. -
_typeListeners
Holds instances of ServiceTypeListener's. -
_cache
Cache for DNSEntry's. -
_services
This hashtable holds the services that have been registered. Keys are instances of String which hold an all lower-case version of the fully qualified service name. Values are instances of ServiceInfo. -
_serviceTypes
This hashtable holds the service types that have been registered or that have been received in an incoming datagram.
Keys are instances of String which hold an all lower-case version of the fully qualified service type.
Values hold the fully qualified service type. -
_delegate
-
_threadSleepDurationMs
protected final long _threadSleepDurationMs -
_shutdown
This is the shutdown hook, we registered with the java runtime. -
_localHost
Handle on the local host -
_incomingListener
-
_throttle
private int _throttleThrottle count. This is used to count the overall number of probes sent by JmDNS. When the last throttle increment happened . -
_lastThrottleIncrement
private long _lastThrottleIncrementLast throttle increment. -
_executor
-
_random
The source for random values. This is used to introduce random delays in responses. This reduces the potential for collisions on the network. -
_ioLock
This lock is used to coordinate processing of incoming and outgoing messages. This is needed, because the Rendezvous Conformance Test does not forgive race conditions. -
_plannedAnswer
If an incoming package which needs an answer is truncated, we store it here. We add more incoming DNSRecords to it, until the JmDNS.Responder timer picks it up.
FIXME [PJYF June 8 2010]: This does not work well with multiple planned answers for packages that came in from different clients. -
_serviceCollectors
This hashtable is used to maintain a list of service types being collected by this JmDNS instance. The key of the hashtable is a service type name, the value is an instance of JmDNS.ServiceCollector.- See Also:
-
_name
-
_recoverLock
-
-
Constructor Details
-
JmDNSImpl
Create an instance of JmDNS and bind it to a specific network interface given its IP-address.- Parameters:
address
- IP address to bind to.name
- name of the newly created JmDNS- Throws:
IOException
-
JmDNSImpl
Create an instance of JmDNS and bind it to a specific network interface given its IP-address.- Parameters:
address
- IP address to bind to.name
- name of the newly created JmDNSthreadSleepDurationMs
- time in milliseconds that the JmDNS listener thread should sleep between multicast receives- Throws:
IOException
-
-
Method Details
-
main
Main method to display API information if run from java -jar- Parameters:
argv
- the command line arguments
-
start
-
openMulticastSocket
- Throws:
IOException
-
closeMulticastSocket
private void closeMulticastSocket() -
advanceState
Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
advanceState
in interfaceDNSStatefulObject
- Parameters:
task
- associated task- Returns:
true
if the state was changed by this thread,false
otherwise.- See Also:
-
revertState
public boolean revertState()Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
revertState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.- See Also:
-
cancelState
public boolean cancelState()Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
cancelState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.
-
closeState
public boolean closeState()Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
closeState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.
-
recoverState
public boolean recoverState()Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
recoverState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.
-
getDns
Returns the DNS associated with this object.- Specified by:
getDns
in interfaceDNSStatefulObject
- Returns:
- DNS resolver
-
associateWithTask
Sets the task associated with this Object.- Specified by:
associateWithTask
in interfaceDNSStatefulObject
- Parameters:
task
- associated taskstate
- state of the task
-
removeAssociationWithTask
Remove the association of the task with this Object.- Specified by:
removeAssociationWithTask
in interfaceDNSStatefulObject
- Parameters:
task
- associated task
-
isAssociatedWithTask
Checks if this object is associated with the task and in the same state.- Specified by:
isAssociatedWithTask
in interfaceDNSStatefulObject
- Parameters:
task
- associated taskstate
- state of the task- Returns:
true
is the task is associated with this object,false
otherwise.
-
isProbing
public boolean isProbing()Returns true, if this is a probing state.- Specified by:
isProbing
in interfaceDNSStatefulObject
- Returns:
true
if probing state,false
otherwise
-
isAnnouncing
public boolean isAnnouncing()Returns true, if this is an announcing state.- Specified by:
isAnnouncing
in interfaceDNSStatefulObject
- Returns:
true
if announcing state,false
otherwise
-
isAnnounced
public boolean isAnnounced()Returns true, if this is an announced state.- Specified by:
isAnnounced
in interfaceDNSStatefulObject
- Returns:
true
if announced state,false
otherwise
-
isCanceling
public boolean isCanceling()Returns true, if this is a canceling state.- Specified by:
isCanceling
in interfaceDNSStatefulObject
- Returns:
true
if canceling state,false
otherwise
-
isCanceled
public boolean isCanceled()Returns true, if this is a canceled state.- Specified by:
isCanceled
in interfaceDNSStatefulObject
- Returns:
true
if canceled state,false
otherwise
-
isClosing
public boolean isClosing()Returns true, if this is a closing state.- Specified by:
isClosing
in interfaceDNSStatefulObject
- Returns:
true
if closing state,false
otherwise
-
isClosed
public boolean isClosed()Returns true, if this is a closed state.- Specified by:
isClosed
in interfaceDNSStatefulObject
- Returns:
true
if closed state,false
otherwise
-
waitForAnnounced
public boolean waitForAnnounced(long timeout) Waits for the object to be announced.- Specified by:
waitForAnnounced
in interfaceDNSStatefulObject
- Parameters:
timeout
- the maximum time to wait in milliseconds.- Returns:
true
if the object is announced,false
otherwise
-
waitForCanceled
public boolean waitForCanceled(long timeout) Waits for the object to be canceled.- Specified by:
waitForCanceled
in interfaceDNSStatefulObject
- Parameters:
timeout
- the maximum time to wait in milliseconds.- Returns:
true
if the object is canceled,false
otherwise
-
getCache
Return the DNSCache associated with the cache variable- Returns:
- DNS cache
-
getName
Return the name of the JmDNS instance. This is an arbitrary string that is useful for distinguishing instances. -
getHostName
Return the HostName associated with this JmDNS instance. Note: May not be the same as what started. The host name is subject to negotiation.- Specified by:
getHostName
in classJmDNS
- Returns:
- Host name
-
getLocalHost
Returns the local host info- Returns:
- local host info
-
getInetAddress
Return the address of the interface to which this instance of JmDNS is bound.- Specified by:
getInetAddress
in classJmDNS
- Returns:
- Internet Address
- Throws:
IOException
- if there is an error in the underlying protocol, such as a TCP error.
-
getInterface
Deprecated.Return the address of the interface to which this instance of JmDNS is bound.- Specified by:
getInterface
in classJmDNS
- Returns:
- Internet Address
- Throws:
IOException
- if there is an error in the underlying protocol, such as a TCP error.
-
getServiceInfo
Get service information. If the information is not cached, the method will block until updated information is received. Usage note: Do not call this method from the AWT event dispatcher thread. You will make the user interface unresponsive.- Specified by:
getServiceInfo
in classJmDNS
- Parameters:
type
- fully qualified service type, such as_http._tcp.local.
.name
- unqualified service name, such asfoobar
.- Returns:
- null if the service information cannot be obtained
-
getServiceInfo
Get service information. If the information is not cached, the method will block for the given timeout until updated information is received. Usage note: If you call this method from the AWT event dispatcher thread, use a small timeout, or you will make the user interface unresponsive.- Specified by:
getServiceInfo
in classJmDNS
- Parameters:
type
- full qualified service type, such as_http._tcp.local.
.name
- unqualified service name, such asfoobar
.timeout
- timeout in milliseconds. Typical timeout should be 5s.- Returns:
- null if the service information cannot be obtained
-
getServiceInfo
Get service information. If the information is not cached, the method will block until updated information is received. Usage note: Do not call this method from the AWT event dispatcher thread. You will make the user interface unresponsive.- Specified by:
getServiceInfo
in classJmDNS
- Parameters:
type
- fully qualified service type, such as_http._tcp.local.
.name
- unqualified service name, such asfoobar
.persistent
- iftrue
ServiceListener.resolveService will be called whenever new new information is received.- Returns:
- null if the service information cannot be obtained
-
getServiceInfo
Get service information. If the information is not cached, the method will block for the given timeout until updated information is received. Usage note: If you call this method from the AWT event dispatcher thread, use a small timeout, or you will make the user interface unresponsive.- Specified by:
getServiceInfo
in classJmDNS
- Parameters:
type
- full qualified service type, such as_http._tcp.local.
.name
- unqualified service name, such asfoobar
.persistent
- iftrue
ServiceListener.resolveService will be called whenever new new information is received.timeout
- timeout in milliseconds. Typical timeout should be 5s.- Returns:
- null if the service information cannot be obtained
-
resolveServiceInfo
-
getServiceInfoFromCache
ServiceInfoImpl getServiceInfoFromCache(String type, String name, String subtype, boolean persistent) -
waitForInfoData
-
requestServiceInfo
Request service information. The information about the service is requested and the ServiceListener.resolveService method is called as soon as it is available. Usage note: Do not call this method from the AWT event dispatcher thread. You will make the user interface unresponsive.- Specified by:
requestServiceInfo
in classJmDNS
- Parameters:
type
- full qualified service type, such as_http._tcp.local.
.name
- unqualified service name, such asfoobar
.
-
requestServiceInfo
Request service information. The information about the service is requested and the ServiceListener.resolveService method is called as soon as it is available. Usage note: Do not call this method from the AWT event dispatcher thread. You will make the user interface unresponsive.- Specified by:
requestServiceInfo
in classJmDNS
- Parameters:
type
- full qualified service type, such as_http._tcp.local.
.name
- unqualified service name, such asfoobar
.persistent
- iftrue
ServiceListener.resolveService will be called whenever new new information is received.
-
requestServiceInfo
Request service information. The information about the service is requested and the ServiceListener.resolveService method is called as soon as it is available.- Specified by:
requestServiceInfo
in classJmDNS
- Parameters:
type
- full qualified service type, such as_http._tcp.local.
.name
- unqualified service name, such asfoobar
.timeout
- timeout in milliseconds
-
requestServiceInfo
Request service information. The information about the service is requested and the ServiceListener.resolveService method is called as soon as it is available.- Specified by:
requestServiceInfo
in classJmDNS
- Parameters:
type
- full qualified service type, such as_http._tcp.local.
.name
- unqualified service name, such asfoobar
.persistent
- iftrue
ServiceListener.resolveService will be called whenever new new information is received.timeout
- timeout in milliseconds
-
handleServiceResolved
-
addServiceTypeListener
Listen for service types.- Specified by:
addServiceTypeListener
in classJmDNS
- Parameters:
listener
- listener for service types- Throws:
IOException
- if there is an error in the underlying protocol, such as a TCP error.
-
removeServiceTypeListener
Remove listener for service types.- Specified by:
removeServiceTypeListener
in classJmDNS
- Parameters:
listener
- listener for service types
-
addServiceListener
Listen for services of a given type. The type has to be a fully qualified type name such as_http._tcp.local.
.- Specified by:
addServiceListener
in classJmDNS
- Parameters:
type
- full qualified service type, such as_http._tcp.local.
.listener
- listener for service updates
-
addServiceListener
-
removeServiceListener
Remove listener for services of a given type.- Specified by:
removeServiceListener
in classJmDNS
- Parameters:
type
- full qualified service type, such as_http._tcp.local.
.listener
- listener for service updates
-
registerService
Register a service. The service is registered for access by other jmdns clients. The name of the service may be changed to make it unique.
Note that the givenServiceInfo
is bound to thisJmDNS
instance, and should not be reused for any other JmDNS.registerService(ServiceInfo).- Specified by:
registerService
in classJmDNS
- Parameters:
infoAbstract
- service info to register- Throws:
IOException
- if there is an error in the underlying protocol, such as a TCP error.
-
unregisterService
Unregister a service. The service should have been registered.Note: Unregistered services will not disappear form the list of services immediately. According to the specification, when unregistering services we send goodbye packets and then wait 1s before purging the cache.
This is support for shared records that can be rescued by some other cooperation DNS.Clients receiving a Multicast DNS Response with a TTL of zero SHOULD NOT immediately delete the record from the cache, but instead record a TTL of 1 and then delete the record one second later.
- Specified by:
unregisterService
in classJmDNS
- Parameters:
infoAbstract
- service info to remove
-
unregisterAllServices
public void unregisterAllServices()Unregister all services.- Specified by:
unregisterAllServices
in classJmDNS
-
registerServiceType
Register a service type. If this service type was not already known, all service listeners will be notified of the new service type.Service types are automatically registered as they are discovered.
- Specified by:
registerServiceType
in classJmDNS
- Parameters:
type
- full qualified service type, such as_http._tcp.local.
.- Returns:
true
if the type or subtype was added,false
if the type was already registered.
-
makeServiceNameUnique
Generate a possibly unique name for a service using the information we have in the cache.- Returns:
- returns true, if the name of the service info had to be changed.
-
addListener
Add a listener for a question. The listener will receive updates of answers to the question as they arrive, or from the cache if they are already available.- Parameters:
listener
- DSN listenerquestion
- DNS query
-
removeListener
Remove a listener from all outstanding questions. The listener will no longer receive any updates.- Parameters:
listener
- DSN listener
-
renewServiceCollector
Renew a service when the record become stale. If there is no service collector for the type this method does nothing.- Parameters:
type
- Service Type
-
updateRecord
Notify all listeners that a record was updated.- Parameters:
now
- update daterec
- DNS recordoperation
- DNS cache operation
-
removeObsoleteDnsListener
-
handleRecord
-
isOlderThanOneSecond
- Parameters:
dnsRecord
-timeToCompare
- a given times for comparison- Returns:
- true if dnsRecord create time is older than 1 second, relative to the given time; false otherwise
-
handleResponse
Handle an incoming response. Cache answers, and pass them on to the appropriate questions.- Throws:
IOException
-
aRecordsLast
In case the a record is received before the srv record the ip address would not be set.Wireshark record: see also file a_record_before_srv.pcapng and
invalid reference
ServiceInfoImplTest#test_ip_address_is_set()
Multicast Domain Name System (response) Transaction ID: 0x0000 Flags: 0x8400 Standard query response, No error Questions: 0 Answer RRs: 2 Authority RRs: 0 Additional RRs: 8 Answers _ibisip_http._tcp.local: type PTR, class IN, DeviceManagementService._ibisip_http._tcp.local _ibisip_http._tcp.local: type PTR, class IN, PassengerCountingService._ibisip_http._tcp.local Additional records DeviceManagementService._ibisip_http._tcp.local: type TXT, class IN, cache flush PassengerCountingService._ibisip_http._tcp.local: type TXT, class IN, cache flush DIST500_7-F07_OC030_05_03941.local: type A, class IN, cache flush, addr 192.168.88.236 DeviceManagementService._ibisip_http._tcp.local: type SRV, class IN, cache flush, priority 0, weight 0, port 5000, target DIST500_7-F07_OC030_05_03941.local PassengerCountingService._ibisip_http._tcp.local: type SRV, class IN, cache flush, priority 0, weight 0, port 5001, target DIST500_7-F07_OC030_05_03941.local DeviceManagementService._ibisip_http._tcp.local: type NSEC, class IN, cache flush, next domain name DeviceManagementService._ibisip_http._tcp.local PassengerCountingService._ibisip_http._tcp.local: type NSEC, class IN, cache flush, next domain name PassengerCountingService._ibisip_http._tcp.local DIST500_7-F07_OC030_05_03941.local: type NSEC, class IN, cache flush, next domain name DIST500_7-F07_OC030_05_03941.local
-
handleQuery
Handle an incoming query. See if we can answer any part of it given our service infos.- Parameters:
in
-addr
-port
-- Throws:
IOException
-
respondToQuery
-
addAnswer
public DNSOutgoing addAnswer(DNSIncoming in, InetAddress addr, int port, DNSOutgoing out, DNSRecord rec) throws IOException Add an answer to a question. Deal with the case when the outgoing packet overflows- Parameters:
in
-addr
-port
-out
-rec
-- Returns:
- outgoing answer
- Throws:
IOException
-
send
Send an outgoing multicast DNS message.- Parameters:
out
-- Throws:
IOException
-
purgeTimer
public void purgeTimer()Description copied from interface:DNSTaskStarter
Purge the general task timer- Specified by:
purgeTimer
in interfaceDNSTaskStarter
-
purgeStateTimer
public void purgeStateTimer()Description copied from interface:DNSTaskStarter
Purge the state task timer- Specified by:
purgeStateTimer
in interfaceDNSTaskStarter
-
cancelTimer
public void cancelTimer()Description copied from interface:DNSTaskStarter
Cancel the generals task timer- Specified by:
cancelTimer
in interfaceDNSTaskStarter
-
cancelStateTimer
public void cancelStateTimer()Description copied from interface:DNSTaskStarter
Cancel the state task timer- Specified by:
cancelStateTimer
in interfaceDNSTaskStarter
-
startProber
public void startProber()Description copied from interface:DNSTaskStarter
Start a new prober task- Specified by:
startProber
in interfaceDNSTaskStarter
-
startAnnouncer
public void startAnnouncer()Description copied from interface:DNSTaskStarter
Start a new announcer task- Specified by:
startAnnouncer
in interfaceDNSTaskStarter
-
startRenewer
public void startRenewer()Description copied from interface:DNSTaskStarter
Start a new renewer task- Specified by:
startRenewer
in interfaceDNSTaskStarter
-
startCanceler
public void startCanceler()Description copied from interface:DNSTaskStarter
Start a new canceler task- Specified by:
startCanceler
in interfaceDNSTaskStarter
-
startReaper
public void startReaper()Description copied from interface:DNSTaskStarter
Start a new reaper task. There is only supposed to be one reaper running at a time.- Specified by:
startReaper
in interfaceDNSTaskStarter
-
startServiceInfoResolver
Description copied from interface:DNSTaskStarter
Start a new service info resolver task- Specified by:
startServiceInfoResolver
in interfaceDNSTaskStarter
- Parameters:
info
- service info to resolve
-
startTypeResolver
public void startTypeResolver()Description copied from interface:DNSTaskStarter
Start a new service type resolver task- Specified by:
startTypeResolver
in interfaceDNSTaskStarter
-
startServiceResolver
Description copied from interface:DNSTaskStarter
Start a new service resolver task- Specified by:
startServiceResolver
in interfaceDNSTaskStarter
- Parameters:
type
- service type to resolve
-
startResponder
Description copied from interface:DNSTaskStarter
Start a new responder task- Specified by:
startResponder
in interfaceDNSTaskStarter
- Parameters:
in
- incoming messageaddr
- incoming addressport
- incoming port
-
recover
public void recover()Recover jmDNS when there is an error. -
__recover
void __recover() -
cleanCache
public void cleanCache()Checks the cache of expired records and removes them. If any records are about to expire it tries to get them refreshed.Implementation note:
This method is called by theRecordReaper
everyDNSConstants.RECORD_REAPER_INTERVAL
milliseconds.- See Also:
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
printServices
Deprecated.List Services and serviceTypes. Debugging Only- Specified by:
printServices
in classJmDNS
-
toString
-
list
Returns a list of service infos of the specified type. -
list
Returns a list of service infos of the specified type. -
listBySubtype
Returns a list of service infos of the specified type sorted by subtype. Any service that do not register a subtype is listed in the empty subtype section.- Specified by:
listBySubtype
in classJmDNS
- Parameters:
type
- Service type name, such as_http._tcp.local.
.- Returns:
- A dictionary of service info by subtypes.
-
listBySubtype
Returns a list of service infos of the specified type sorted by subtype. Any service that do not register a subtype is listed in the empty subtype section.- Specified by:
listBySubtype
in classJmDNS
- Parameters:
type
- Service type name, such as_http._tcp.local.
.timeout
- timeout in milliseconds. Typical timeout should be 6s.- Returns:
- A dictionary of service info by subtypes.
-
disposeServiceCollectors
private void disposeServiceCollectors()This method disposes all ServiceCollector instances which have been created by calls to methodlist(type)
.- See Also:
-
toUnqualifiedName
-
getServices
-
setLastThrottleIncrement
public void setLastThrottleIncrement(long lastThrottleIncrement) -
getLastThrottleIncrement
public long getLastThrottleIncrement() -
setThrottle
public void setThrottle(int throttle) -
getThrottle
public int getThrottle() -
getRandom
-
ioLock
public void ioLock() -
ioUnlock
public void ioUnlock() -
setPlannedAnswer
-
getPlannedAnswer
-
setLocalHost
-
getServiceTypes
-
getSocket
-
getGroup
-
getDelegate
Description copied from class:JmDNS
Returns the instance delegate- Specified by:
getDelegate
in classJmDNS
- Returns:
- instance delegate
-
setDelegate
Description copied from class:JmDNS
Sets the instance delegate- Specified by:
setDelegate
in classJmDNS
- Parameters:
delegate
- new instance delegate- Returns:
- previous instance delegate
-