|
JmDNS 3.4.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.jmdns.JmDNS javax.jmdns.impl.JmDNSImpl
public class JmDNSImpl
mDNS implementation in Java.
Nested Class Summary | |
---|---|
static class |
JmDNSImpl.Operation
|
static class |
JmDNSImpl.ServiceTypeEntry
This is used to store type entries. |
protected class |
JmDNSImpl.Shutdown
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 | |
---|---|
protected Thread |
_shutdown
This is the shutdown hook, we registered with the java runtime. |
Fields inherited from class javax.jmdns.JmDNS |
---|
VERSION |
Constructor Summary | |
---|---|
JmDNSImpl(InetAddress address,
String name)
Create an instance of JmDNS and bind it to a specific network interface given its IP-address. |
Method Summary | |
---|---|
DNSOutgoing |
addAnswer(DNSIncoming in,
InetAddress addr,
int port,
DNSOutgoing out,
DNSRecord rec)
Add an answer to a question. |
void |
addListener(javax.jmdns.impl.DNSListener listener,
DNSQuestion question)
Add a listener for a question. |
void |
addServiceListener(String type,
ServiceListener listener)
Listen for services of a given type. |
void |
addServiceTypeListener(ServiceTypeListener listener)
Listen for service types. |
boolean |
advanceState(DNSTask task)
Sets the state and notifies all objects that wait on the ServiceInfo. |
void |
associateWithTask(DNSTask task,
DNSState state)
Sets the task associated with this Object. |
boolean |
cancelState()
Sets the state and notifies all objects that wait on the ServiceInfo. |
void |
cancelStateTimer()
Cancel the state task timer |
void |
cancelTimer()
Cancel the generals task timer |
void |
cleanCache()
|
void |
close()
|
boolean |
closeState()
Sets the state and notifies all objects that wait on the ServiceInfo. |
DNSCache |
getCache()
Return the DNSCache associated with the cache variable |
JmDNS.Delegate |
getDelegate()
Returns the instance delegate |
JmDNSImpl |
getDns()
Returns the DNS associated with this object. |
InetAddress |
getGroup()
|
String |
getHostName()
Return the HostName associated with this JmDNS instance. |
InetAddress |
getInterface()
Return the address of the interface to which this instance of JmDNS is bound. |
long |
getLastThrottleIncrement()
|
HostInfo |
getLocalHost()
Returns the local host info |
String |
getName()
Return the name of the JmDNS instance. |
DNSIncoming |
getPlannedAnswer()
|
static Random |
getRandom()
|
ServiceInfo |
getServiceInfo(String type,
String name)
Get service information. |
ServiceInfo |
getServiceInfo(String type,
String name,
boolean persistent)
Get service information. |
ServiceInfo |
getServiceInfo(String type,
String name,
boolean persistent,
long timeout)
Get service information. |
ServiceInfo |
getServiceInfo(String type,
String name,
long timeout)
Get service information. |
Map<String,ServiceInfo> |
getServices()
|
Map<String,JmDNSImpl.ServiceTypeEntry> |
getServiceTypes()
|
MulticastSocket |
getSocket()
|
int |
getThrottle()
|
void |
ioLock()
|
void |
ioUnlock()
|
boolean |
isAnnounced()
Returns true, if this is an announced state. |
boolean |
isAnnouncing()
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 |
isCanceled()
Returns true, if this is a canceled state. |
boolean |
isCanceling()
Returns true, if this is a canceling state. |
boolean |
isClosed()
Returns true, if this is a closed state. |
boolean |
isClosing()
Returns true, if this is a closing state. |
boolean |
isProbing()
Returns true, if this is a probing state. |
ServiceInfo[] |
list(String type)
Returns a list of service infos of the specified type. |
ServiceInfo[] |
list(String type,
long timeout)
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(String[] argv)
Main method to display API information if run from java -jar |
void |
printServices()
Deprecated. |
void |
purgeStateTimer()
Purge the state task timer |
void |
purgeTimer()
Purge the general task timer |
void |
recover()
Recover jmdns when there is an error. |
boolean |
recoverState()
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 |
removeAssociationWithTask(DNSTask task)
Remove the association of the task with this Object. |
void |
removeListener(javax.jmdns.impl.DNSListener listener)
Remove a listener from all outstanding questions. |
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(DNSRecord record)
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. |
void |
respondToQuery(DNSIncoming in)
|
boolean |
revertState()
Sets the state and notifies all objects that wait on the ServiceInfo. |
void |
send(DNSOutgoing out)
Send an outgoing multicast DNS message. |
JmDNS.Delegate |
setDelegate(JmDNS.Delegate delegate)
Sets the instance delegate |
void |
setLastThrottleIncrement(long lastThrottleIncrement)
|
void |
setPlannedAnswer(DNSIncoming plannedAnswer)
|
void |
setThrottle(int throttle)
|
void |
startAnnouncer()
Start a new announcer task |
void |
startCanceler()
Start a new canceler task |
void |
startProber()
Start a new prober task |
void |
startReaper()
Start a new reaper task. |
void |
startRenewer()
Start a new renewer task |
void |
startResponder(DNSIncoming in,
int port)
Start a new responder task |
void |
startServiceInfoResolver(ServiceInfoImpl info)
Start a new service info resolver task |
void |
startServiceResolver(String type)
Start a new service resolver task |
void |
startTypeResolver()
Start a new service type resolver task |
String |
toString()
|
void |
unregisterAllServices()
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. |
Methods inherited from class javax.jmdns.JmDNS |
---|
create, create, create, create |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Thread _shutdown
Constructor Detail |
---|
public JmDNSImpl(InetAddress address, String name) throws IOException
address
- IP address to bind to.name
- name of the newly created JmDNS
IOException
Method Detail |
---|
public static void main(String[] argv)
argv
- the command line argumentspublic boolean advanceState(DNSTask task)
advanceState
in interface DNSStatefulObject
task
- associated task
true
false otherwise.DNSState.advance()
public boolean revertState()
revertState
in interface DNSStatefulObject
true
false otherwise.DNSState.revert()
public boolean cancelState()
cancelState
in interface DNSStatefulObject
true
false otherwise.public boolean closeState()
closeState
in interface DNSStatefulObject
true
false otherwise.public boolean recoverState()
recoverState
in interface DNSStatefulObject
true
false otherwise.public JmDNSImpl getDns()
getDns
in interface DNSStatefulObject
public void associateWithTask(DNSTask task, DNSState state)
associateWithTask
in interface DNSStatefulObject
task
- associated taskstate
- state of the taskpublic void removeAssociationWithTask(DNSTask task)
removeAssociationWithTask
in interface DNSStatefulObject
task
- associated taskpublic boolean isAssociatedWithTask(DNSTask task, DNSState state)
isAssociatedWithTask
in interface DNSStatefulObject
task
- associated taskstate
- state of the task
true
is the task is associated with this object, false
otherwise.public boolean isProbing()
isProbing
in interface DNSStatefulObject
true
if probing state, false
otherwisepublic boolean isAnnouncing()
isAnnouncing
in interface DNSStatefulObject
true
if announcing state, false
otherwisepublic boolean isAnnounced()
isAnnounced
in interface DNSStatefulObject
true
if announced state, false
otherwisepublic boolean isCanceling()
isCanceling
in interface DNSStatefulObject
true
if canceling state, false
otherwisepublic boolean isCanceled()
isCanceled
in interface DNSStatefulObject
true
if canceled state, false
otherwisepublic boolean isClosing()
isClosing
in interface DNSStatefulObject
true
if closing state, false
otherwisepublic boolean isClosed()
isClosed
in interface DNSStatefulObject
true
if closed state, false
otherwisepublic boolean waitForAnnounced(long timeout)
waitForAnnounced
in interface DNSStatefulObject
timeout
- the maximum time to wait in milliseconds.
true
if the object is announced, false
otherwisepublic boolean waitForCanceled(long timeout)
waitForCanceled
in interface DNSStatefulObject
timeout
- the maximum time to wait in milliseconds.
true
if the object is canceled, false
otherwisepublic DNSCache getCache()
public String getName()
getName
in class JmDNS
public String getHostName()
getHostName
in class JmDNS
public HostInfo getLocalHost()
public InetAddress getInterface() throws IOException
getInterface
in class JmDNS
IOException
- if there is an error in the underlying protocol, such as a TCP error.public ServiceInfo getServiceInfo(String type, String name)
getServiceInfo
in class JmDNS
type
- fully qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.
public ServiceInfo getServiceInfo(String type, String name, long timeout)
getServiceInfo
in class JmDNS
type
- full qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.timeout
- timeout in milliseconds. Typical timeout should be 5s.
public ServiceInfo getServiceInfo(String type, String name, boolean persistent)
getServiceInfo
in class JmDNS
type
- fully qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.persistent
- if true
ServiceListener.resolveService will be called whenever new new information is received.
public ServiceInfo getServiceInfo(String type, String name, boolean persistent, long timeout)
getServiceInfo
in class JmDNS
type
- full qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.persistent
- if true
ServiceListener.resolveService will be called whenever new new information is received.timeout
- timeout in milliseconds. Typical timeout should be 5s.
public void requestServiceInfo(String type, String name)
requestServiceInfo
in class JmDNS
type
- full qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.public void requestServiceInfo(String type, String name, boolean persistent)
requestServiceInfo
in class JmDNS
type
- full qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.persistent
- if true
ServiceListener.resolveService will be called whenever new new information is received.public void requestServiceInfo(String type, String name, long timeout)
requestServiceInfo
in class JmDNS
type
- full qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.timeout
- timeout in millisecondspublic void requestServiceInfo(String type, String name, boolean persistent, long timeout)
requestServiceInfo
in class JmDNS
type
- full qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.persistent
- if true
ServiceListener.resolveService will be called whenever new new information is received.timeout
- timeout in millisecondspublic void addServiceTypeListener(ServiceTypeListener listener) throws IOException
addServiceTypeListener
in class JmDNS
listener
- listener for service types
IOException
- if there is an error in the underlying protocol, such as a TCP error.public void removeServiceTypeListener(ServiceTypeListener listener)
removeServiceTypeListener
in class JmDNS
listener
- listener for service typespublic void addServiceListener(String type, ServiceListener listener)
_http._tcp.local.
.
addServiceListener
in class JmDNS
type
- full qualified service type, such as _http._tcp.local.
.listener
- listener for service updatespublic void removeServiceListener(String type, ServiceListener listener)
removeServiceListener
in class JmDNS
type
- full qualified service type, such as _http._tcp.local.
.listener
- listener for service updatespublic void registerService(ServiceInfo infoAbstract) throws IOException
ServiceInfo
is bound to this JmDNS
instance, and should not be reused for any other JmDNS.registerService(ServiceInfo).
registerService
in class JmDNS
infoAbstract
- service info to register
IOException
- if there is an error in the underlying protocol, such as a TCP error.public void unregisterService(ServiceInfo infoAbstract)
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.
unregisterService
in class JmDNS
infoAbstract
- service info to removepublic void unregisterAllServices()
unregisterAllServices
in class JmDNS
public boolean registerServiceType(String type)
Service types are automatically registered as they are discovered.
registerServiceType
in class JmDNS
type
- full qualified service type, such as _http._tcp.local.
.
true
if the type or subtype was added, false
if the type was already registered.public void addListener(javax.jmdns.impl.DNSListener listener, DNSQuestion question)
listener
- DSN listenerquestion
- DNS querypublic void removeListener(javax.jmdns.impl.DNSListener listener)
listener
- DSN listenerpublic void renewServiceCollector(DNSRecord record)
record
- DNS recordpublic void updateRecord(long now, DNSRecord rec, JmDNSImpl.Operation operation)
now
- update daterec
- DNS recordoperation
- DNS cache operationpublic void respondToQuery(DNSIncoming in)
public DNSOutgoing addAnswer(DNSIncoming in, InetAddress addr, int port, DNSOutgoing out, DNSRecord rec) throws IOException
in
- addr
- port
- out
- rec
-
IOException
public void send(DNSOutgoing out) throws IOException
out
-
IOException
public void purgeTimer()
DNSTaskStarter
purgeTimer
in interface DNSTaskStarter
public void purgeStateTimer()
DNSTaskStarter
purgeStateTimer
in interface DNSTaskStarter
public void cancelTimer()
DNSTaskStarter
cancelTimer
in interface DNSTaskStarter
public void cancelStateTimer()
DNSTaskStarter
cancelStateTimer
in interface DNSTaskStarter
public void startProber()
DNSTaskStarter
startProber
in interface DNSTaskStarter
public void startAnnouncer()
DNSTaskStarter
startAnnouncer
in interface DNSTaskStarter
public void startRenewer()
DNSTaskStarter
startRenewer
in interface DNSTaskStarter
public void startCanceler()
DNSTaskStarter
startCanceler
in interface DNSTaskStarter
public void startReaper()
DNSTaskStarter
startReaper
in interface DNSTaskStarter
public void startServiceInfoResolver(ServiceInfoImpl info)
DNSTaskStarter
startServiceInfoResolver
in interface DNSTaskStarter
info
- service info to resolvepublic void startTypeResolver()
DNSTaskStarter
startTypeResolver
in interface DNSTaskStarter
public void startServiceResolver(String type)
DNSTaskStarter
startServiceResolver
in interface DNSTaskStarter
type
- service type to resolvepublic void startResponder(DNSIncoming in, int port)
DNSTaskStarter
startResponder
in interface DNSTaskStarter
in
- incoming messageport
- incoming portpublic void recover()
public void cleanCache()
public void close()
close
in interface Closeable
@Deprecated public void printServices()
printServices
in class JmDNS
public String toString()
toString
in class Object
public ServiceInfo[] list(String type)
list
in class JmDNS
type
- Service type name, such as _http._tcp.local.
.
public ServiceInfo[] list(String type, long timeout)
list
in class JmDNS
type
- Service type name, such as _http._tcp.local.
.timeout
- timeout in milliseconds. Typical timeout should be 6s.
public Map<String,ServiceInfo[]> listBySubtype(String type)
listBySubtype
in class JmDNS
type
- Service type name, such as _http._tcp.local.
.
public Map<String,ServiceInfo[]> listBySubtype(String type, long timeout)
listBySubtype
in class JmDNS
type
- Service type name, such as _http._tcp.local.
.timeout
- timeout in milliseconds. Typical timeout should be 6s.
public Map<String,ServiceInfo> getServices()
public void setLastThrottleIncrement(long lastThrottleIncrement)
public long getLastThrottleIncrement()
public void setThrottle(int throttle)
public int getThrottle()
public static Random getRandom()
public void ioLock()
public void ioUnlock()
public void setPlannedAnswer(DNSIncoming plannedAnswer)
public DNSIncoming getPlannedAnswer()
public Map<String,JmDNSImpl.ServiceTypeEntry> getServiceTypes()
public MulticastSocket getSocket()
public InetAddress getGroup()
public JmDNS.Delegate getDelegate()
JmDNS
getDelegate
in class JmDNS
public JmDNS.Delegate setDelegate(JmDNS.Delegate delegate)
JmDNS
setDelegate
in class JmDNS
delegate
- new instance delegate
|
Last updated 2011-08-25 12:40 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |