I am using NSNetServiceBrowser
to find NSNetService
of Apple TV
over bonjour
connection. Now my code works almost every time. But every once in a while (1 out of 10 times) NSNetServiceBrowser
is not able to find NSNetService
of Apple TV
or taking awful amount of time to find it.
Once NSNetServiceBrowser
is unable to detect Apple TV
, I have to restart the Apple TV
and again everything starts working normally.
I am not able to understand what is the problem and how restarting the Apple TV
solves it. So I am looking for any guidance or suggestion to pin point the problem.
Code for Apple TV :
service = [[NSNetService alloc] initWithDomain:@"" type:@"_test._tcp" name:@"TV ZohoShow" port:0]; [service scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; service.includesPeerToPeer = YES; if(service) { [service setDelegate:self]; [service publishWithOptions:NSNetServiceListenForConnections]; }
Code for iOS device:
[serviceBrowser scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; serviceBrowser.includesPeerToPeer = YES; [serviceBrowser setDelegate:self]; [serviceBrowser searchForServicesOfType:@"_test._tcp" inDomain:@""];
UPDATE: It never happens when I try the connection between two iOS devices. I get the connection 100/100 times in that case. But as soon as I introduce Apple TV, I start getting those occasions where TV won't be found.
0 comments:
Post a Comment