2

I think this may be an iOS bug.

I run the following simple code, to broadcast a net service:

self.netService = [[NSNetService alloc] initWithDomain:@"local."
                                                          type:@"_testnetwork._tcp."
                                                          name:[[UIDevice currentDevice] name]
                                                          port:port];
self.netService.delegate = self;
[self.netService publish];

On another device, I run this code, to detect net services:

self.netServiceBrowser = [[NSNetServiceBrowser alloc] init];
self.netServiceBrowser.delegate = (id)self;
[self.netServiceBrowser searchForServicesOfType:@"_testnetwork._tcp." inDomain:@"local."];

What proceeds to happen is that the browser will detect when the net service appears for the first time, and then when the service goes away, most of the time it won't detect it, and still thinks the NSNetService is still broadcasting. Interestingly, the apps can be stopped on both devices and the browser can be started and will still detect the old service as being currently broadcast - it hangs around.

Using this code in terminal on mac shows correctly when the services appear and disappear:

dns-sd -B _test._tcp

Any solution to this problem? Is this an iOS bug?

Andrew
  • 15,935
  • 28
  • 121
  • 203

0 Answers0