javax.jmdns
Class JmDNS

java.lang.Object
  extended by javax.jmdns.JmDNS
Direct Known Subclasses:
JmDNSImpl

public abstract class JmDNS
extends java.lang.Object

mDNS implementation in Java.


Field Summary
static java.lang.String VERSION
          The version of JmDNS.
 
Constructor Summary
JmDNS()
           
 
Method Summary
abstract  void addServiceListener(java.lang.String type, ServiceListener listener)
          Listen for services of a given type.
abstract  void addServiceTypeListener(ServiceTypeListener listener)
          Listen for service types.
abstract  void close()
          Close down jmdns.
static JmDNS create()
          Create an instance of JmDNS.
static JmDNS create(java.net.InetAddress addr)
          Create an instance of JmDNS and bind it to a specific network interface given its IP-address.
abstract  java.lang.String getHostName()
          Return the HostName associated with this JmDNS instance.
abstract  java.net.InetAddress getInterface()
          Return the address of the interface to which this instance of JmDNS is bound.
abstract  ServiceInfo getServiceInfo(java.lang.String type, java.lang.String name)
          Get service information.
abstract  ServiceInfo getServiceInfo(java.lang.String type, java.lang.String name, int timeout)
          Get service information.
abstract  ServiceInfo[] list(java.lang.String type)
          Returns a list of service infos of the specified type.
abstract  void printServices()
          List Services and serviceTypes.
abstract  void registerService(ServiceInfo info)
          Register a service.
abstract  void registerServiceType(java.lang.String type)
          Register a service type.
abstract  void removeServiceListener(java.lang.String type, ServiceListener listener)
          Remove listener for services of a given type.
abstract  void removeServiceTypeListener(ServiceTypeListener listener)
          Remove listener for service types.
abstract  void requestServiceInfo(java.lang.String type, java.lang.String name)
          Request service information.
abstract  void requestServiceInfo(java.lang.String type, java.lang.String name, int timeout)
          Request service information.
abstract  void unregisterAllServices()
          Unregister all services.
abstract  void unregisterService(ServiceInfo info)
          Unregister a service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static java.lang.String VERSION
The version of JmDNS.

Constructor Detail

JmDNS

public JmDNS()
Method Detail

create

public static JmDNS create()
                    throws java.io.IOException
Create an instance of JmDNS.

Returns:
jmDNS instance
Throws:
java.io.IOException

create

public static JmDNS create(java.net.InetAddress addr)
                    throws java.io.IOException
Create an instance of JmDNS and bind it to a specific network interface given its IP-address.

Parameters:
addr - IP address to bind to.
Returns:
jmDNS instance
Throws:
java.io.IOException

getHostName

public abstract java.lang.String 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.

Returns:
Host name

getInterface

public abstract java.net.InetAddress getInterface()
                                           throws java.io.IOException
Return the address of the interface to which this instance of JmDNS is bound.

Returns:
Internet Address
Throws:
java.io.IOException

getServiceInfo

public abstract ServiceInfo getServiceInfo(java.lang.String type,
                                           java.lang.String name)
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.

Parameters:
type - fully qualified service type, such as _http._tcp.local. .
name - unqualified service name, such as foobar .
Returns:
null if the service information cannot be obtained

getServiceInfo

public abstract ServiceInfo getServiceInfo(java.lang.String type,
                                           java.lang.String name,
                                           int timeout)
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.

Parameters:
type - full qualified service type, such as _http._tcp.local. .
name - unqualified service name, such as foobar .
timeout - timeout in milliseconds
Returns:
null if the service information cannot be obtained

requestServiceInfo

public abstract void requestServiceInfo(java.lang.String type,
                                        java.lang.String name)
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.

Parameters:
type - full qualified service type, such as _http._tcp.local. .
name - unqualified service name, such as foobar .

requestServiceInfo

public abstract void requestServiceInfo(java.lang.String type,
                                        java.lang.String name,
                                        int timeout)
Request service information. The information about the service is requested and the ServiceListener.resolveService method is called as soon as it is available.

Parameters:
type - full qualified service type, such as _http._tcp.local. .
name - unqualified service name, such as foobar .
timeout - timeout in milliseconds

addServiceTypeListener

public abstract void addServiceTypeListener(ServiceTypeListener listener)
                                     throws java.io.IOException
Listen for service types.

Parameters:
listener - listener for service types
Throws:
java.io.IOException

removeServiceTypeListener

public abstract void removeServiceTypeListener(ServiceTypeListener listener)
Remove listener for service types.

Parameters:
listener - listener for service types

addServiceListener

public abstract void addServiceListener(java.lang.String type,
                                        ServiceListener listener)
Listen for services of a given type. The type has to be a fully qualified type name such as _http._tcp.local..

Parameters:
type - full qualified service type, such as _http._tcp.local..
listener - listener for service updates

removeServiceListener

public abstract void removeServiceListener(java.lang.String type,
                                           ServiceListener listener)
Remove listener for services of a given type.

Parameters:
type - full qualified service type, such as _http._tcp.local..
listener - listener for service updates

registerService

public abstract void registerService(ServiceInfo info)
                              throws java.io.IOException
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.

Parameters:
info - service info to register
Throws:
java.io.IOException

unregisterService

public abstract void unregisterService(ServiceInfo info)
Unregister a service. The service should have been registered.

Parameters:
info - service info to remove

unregisterAllServices

public abstract void unregisterAllServices()
Unregister all services.


registerServiceType

public abstract void registerServiceType(java.lang.String type)
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.

Parameters:
type - full qualified service type, such as _http._tcp.local..

close

public abstract void close()
Close down jmdns. Release all resources and unregister all services.


printServices

public abstract void printServices()
List Services and serviceTypes. Debugging Only


list

public abstract ServiceInfo[] list(java.lang.String type)
Returns a list of service infos of the specified type.

Parameters:
type - Service type name, such as _http._tcp.local..
Returns:
An array of service instance names.