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: Shaun Wexler <email@hidden>
- Date: Sun, 9 Apr 2006 15:53:32 -0700
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
_______________________________________________
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