javax.jmdns

Class JmDNS

Known Direct Subclasses:
JmDNSImpl

public abstract class JmDNS
extends java.lang.Object

mDNS implementation in Java.

Field Summary

static String
VERSION
The version of JmDNS.

Method Summary

abstract void
addServiceListener(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(InetAddress addr)
Create an instance of JmDNS and bind it to a specific network interface given its IP-address.
abstract String
getHostName()
Return the HostName associated with this JmDNS instance.
abstract InetAddress
getInterface()
Return the address of the interface to which this instance of JmDNS is bound.
abstract ServiceInfo
getServiceInfo(String type, String name)
Get service information.
abstract ServiceInfo
getServiceInfo(String type, String name, int timeout)
Get service information.
abstract ServiceInfo[]
list(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(String type)
Register a service type.
abstract void
removeServiceListener(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(String type, String name)
Request service information.
abstract void
requestServiceInfo(String type, String name, int timeout)
Request service information.
abstract void
unregisterAllServices()
Unregister all services.
abstract void
unregisterService(ServiceInfo info)
Unregister a service.

Field Details

VERSION

public static String VERSION
The version of JmDNS.

Method Details

addServiceListener

public abstract void addServiceListener(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

addServiceTypeListener

public abstract void addServiceTypeListener(ServiceTypeListener listener)
            throws IOException
Listen for service types.
Parameters:
listener - listener for service types

close

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

create

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

create

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

getHostName

public abstract 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.

getInterface

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

getServiceInfo

public abstract ServiceInfo getServiceInfo(String type,
                                           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(String type,
                                           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

list

public abstract ServiceInfo[] list(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.

printServices

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

registerService

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

registerServiceType

public abstract void registerServiceType(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.

removeServiceListener

public abstract void removeServiceListener(String type,
                                           ServiceListener listener)
Remove listener for services of a given type.
Parameters:
listener - listener for service updates

removeServiceTypeListener

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

requestServiceInfo

public abstract void requestServiceInfo(String type,
                                        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(String type,
                                        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

unregisterAllServices

public abstract void unregisterAllServices()
Unregister all services.

unregisterService

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