by SuperBonBon | ![]() |
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.