mDNS implementation in Java.
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.
.
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.
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.
type
- fully qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.
- 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.
type
- full qualified service type, such as _http._tcp.local.
.name
- unqualified service name, such as foobar
.timeout
- timeout in milliseconds
- 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.
type
- Service type name, such as _http._tcp.local.
.
- 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.
listener
- listener for service updates
removeServiceTypeListener
public abstract void removeServiceTypeListener(ServiceTypeListener listener)
Remove listener for service types.
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.
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.
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.