Re: Bonjour will not resolve in separate thread
Re: Bonjour will not resolve in separate thread
- Subject: Re: Bonjour will not resolve in separate thread
- From: Will Koffel <email@hidden>
- Date: Mon, 10 Apr 2006 12:01:33 -0400
This didn't seem to have any effect, and the bonjour-dev list seems
pretty slow these days. Anyone else have experience running an
NSNetService resolve in something other than the main thread, before
I rearchitect to move lookups elsewhere in my app? I'm aware that
resolve happens in it's own thread through the delegate mechanism of
course. I was just hoping to keep the service lookup in a thread
with other related activity.
-Will
On Apr 9, 2006, at 6:53 PM, Shaun Wexler wrote:
On Apr 9, 2006, at 3:00 PM, Will Koffel wrote:
I'm trying to resolve a Bonjour service. It's happening in a
background thread.
[NSThread detachNewThreadSelector:@selector(loadData:)
toTarget:loader withObject:self];
The loader implements loadData, does nothing right now except
instantiate an autorelease pool and then try to resolve a service:
- (void)loadData:(id)caller {
NSAutoreleasePool *threadPool = [[NSAutoreleasePool alloc] init];
NSNetService *service = [[NSNetService alloc]
initWithDomain:@"local." type:@"_http._tcp."name:@"Steam"];
[service setDelegate:self];
[service resolveWithTimeout:5.0];
[[NSRunLoop currentRunLoop] run];
[threadPool release];
}
- (void)netServiceDidResolveAddress:(NSNetService *)sender {
NSLog(@"resolved %@", sender);
[sender removeFromRunLoop:[NSRunLoop currentRunLoop]];
}
- (void)netService:(NSNetService *)sender didNotResolve:
(NSDictionary *)errorDict {
NSLog(@"failed to resolve %@", sender);
[sender removeFromRunLoop:[NSRunLoop currentRunLoop]];
}
I get the notification that the service "will resolve", but I
never get a resolution or a failure. If I do the same in the main
thread, it works with no problems.
Any ideas? The only thing I've found was a vague reference to
needing an NSRunLoop, but I'm pretty sure that the new thread's
default run loop will work.
Exactly. See above. FWIW, this thread is unnecessary unless you
are going to do a lot more work with it, otherwise just use the
main thread for your resolve (which is performed by the
mDNSResponder process anyhow).
--
Shaun Wexler
MacFOH
http://www.macfoh.com
"A person who never made a mistake never tried anything new." -
Albert Einstein
!DSPAM:4439907c7374006997259!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden