javax.jmdns
Class JmDNS

java.lang.Object
  |
  +--javax.jmdns.DNSConstants
        |
        +--javax.jmdns.JmDNS

public class JmDNS
extends javax.jmdns.DNSConstants

mDNS implementation in Java.


Field Summary
static java.lang.String VERSION
           
 
Constructor Summary
JmDNS()
          Create an instance of JmDNS.
JmDNS(java.net.InetAddress addr)
          Create an instance of JmDNS and bind it to a specific network interface given its IP-address.
 
Method Summary
 void addServiceListener(java.lang.String type, ServiceListener listener)
          Listen for services of a given type.
 void addServiceTypeListener(ServiceTypeListener listener)
          Listen for service types.
 void close()
          Close down jmdns.
 java.net.InetAddress getInterface()
          Return the address of the interface to which this instance of JmDNS is bound.
 ServiceInfo getServiceInfo(java.lang.String type, java.lang.String name)
          Get service information.
 ServiceInfo getServiceInfo(java.lang.String type, java.lang.String name, int timeout)
          Get service information.
 void registerService(ServiceInfo info)
          Register a service.
 void registerServiceType(java.lang.String type)
          Register a service type.
 void removeServiceListener(ServiceListener listener)
          Remove listener for services of a given type.
 void removeServiceTypeListener(ServiceTypeListener listener)
          Remove listener for service types.
 void requestServiceInfo(java.lang.String type, java.lang.String name)
          Request service information.
 void requestServiceInfo(java.lang.String type, java.lang.String name, int timeout)
          Request service information.
 void unregisterAllServices()
          Unregister a service.
 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
Constructor Detail

JmDNS

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


JmDNS

public JmDNS(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.

Method Detail

getInterface

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

java.io.IOException

getServiceInfo

public 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 informatin is received.

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

getServiceInfo

public 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 informatin is received.

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

requestServiceInfo

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


requestServiceInfo

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


addServiceTypeListener

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

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

removeServiceTypeListener

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

Parameters:
listener - listener for service types

addServiceListener

public 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 void removeServiceListener(ServiceListener listener)
Remove listener for services of a given type.

Parameters:
listener - listener for service updates

registerService

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

java.io.IOException

unregisterService

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


unregisterAllServices

public void unregisterAllServices()
Unregister a service.


registerServiceType

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


close

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