Documentation
 
  Discovery
  Messaging
  Eventing
  Rmi
  Jmx
  Security
 
  Built with Apache Forrest logo Financial help logo
 
Designed for Firefox logo 


by SuperBonBon  PDF 

UPNP™ Discovery



Discovering devices

Devices can be found on the network using the net.sbbi.upnp.Discovery class discover(...) methods. The following code snipet show how to discover all root devices on the network :

  UPNPRootDevice[] devices = Discovery.discover();
  if ( devices != null ) {
   for ( int i = 0; i < devices.length; i++ ) {
    System.out.println( "Found device " + devices[i].getModelName() );
   }
  }

You can also search only a specific type of devices using a search target which are usually defined in the devices specs. Here is how to search all Internet Gateway Devices on the network :

  String st = "upnp:schemas-upnp-org:device:InternetGatewayDevice:1";
  UPNPRootDevice[] devices = Discovery.discover( st );
  if ( devices != null ) {
   for ( int i = 0; i < devices.length; i++ ) {
    System.out.println( "Found IGD device " + devices[i].getModelName() );
   }
  }

You can also specify a specific timeout for devices response, try to give enough time to the devices to respond.


 

Copyright © 2005 SuperBonBon Industries. All rights reserved.
Unless otherwise expressly noted, the contents of these pages are licensed under the Creative Commons - Attribution / Share Alike license.