Starting with the example http://developer.android.com/training/connect-devices-wirelessly/nsd.html , I created an application designed to work on multiple devices on the same subnet. Each device registers the same service and tries to find others on the subnet with this service. As described in the document, each time the device registers the service, the name gets distorted with the addition of "(N)", where N is an integer. Each device when it performs ala detection
public void discoverServices() {
mNsdManager.discoverServices(
SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);
}
finds all registered services. I track them in a hash map that saves the detected record NsdServiceInfo.
The problem arises when I try to resolve them. If I repeat hashmap and resolve each NsdServiceInfo, only the first one will succeed. I thought that maybe the problem is that a separate one is required NsdManager.ResolveListener, so I create it for each record NsdServiceInfo, but without joy.
If I block the first service in the hash map, which will be resolved, the next will work. Here is the DDMS output:
07-09 17:11:36.799: D/P2PServiceManager(1958): Resolving services with type : PeerDiscovery
07-09 17:11:36.799: W/P2PServiceManager(1958): Resolving PeerDiscovery services with name : PeerDiscovery (3)
07-09 17:11:36.799: W/P2PServiceManager(1958): Resolving PeerDiscovery services with name : PeerDiscovery (2)
07-09 17:11:36.807: E/P2PServiceManager(1958): RRRRRRRRRRRRRRRRRRR Resolve failed : error code 3
07-09 17:11:36.830: E/P2PServiceManager(1958): RRRRRRRRRRRRRRRRRRR Resolve Succeeded. name: PeerDiscovery\032(3)type: ._http._udphost: /192.168.1.145port: 53221txtRecord: null
I suspect there is some kind of bad code or some other similar problem, but I wonder if anyone else has seen this problem. Google and StackOverflow don't seem to have an answer.
[2014-07-24] , , . , -, NsdManager .