Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFNetServiceResolve - callback never gets called



Hi Ken,

What is kDomainStr defined as? If it's defined as empty string, then that's your problem. You need to pass in the actual domain that was returned in your browse callback when you originally discovered the service. Much of the time, the domain will be "local.", but now that we have wide-area support, it could be anything, so you should not hard code the domain that you pass in to your resolve, and should always use the actual domain of the discovered service.

Best Regards,
-Marc


On Jun 17, 2005, at 8:37 AM, Ken Worley wrote:

Hi all,

I'm hoping someone on the list can help. Beginning with Tiger and continuing on OS X 10.4.1, my resolve callback no longer gets called when I call CFNetServiceResolve in asynchronous mode. This had been working fine through previous system versions. I'm not doing anything fancy - most of the code is almost straight from one of Apple's samples.

I've tried searching the archives for CFNetServiceResolve to no avail.

Here's the relevant code:

CFNetServiceClientContext clientContext = { 0, this, NULL, NULL, NULL };
CFStreamError error;


CFStringRef svcName = /* a name obtained from browsing services */;

CFNetServiceRef resolveSvc = CFNetServiceCreate (kCFAllocatorDefault, kDomainStr,
mServiceTypeStr, svcName, 0);


if (resolveSvc == NULL)
    return;

if (CFNetServiceSetClient(resolveSvc, MyResolveCallback, &clientContext))
{
CFNetServiceScheduleWithRunLoop(resolveSvc, CFRunLoopGetCurrent (), kCFRunLoopCommonModes);


bool resolutionStarted;
if (TigerOrLater())
resolutionStarted = CFNetServiceResolveWithTimeout (resolveSvc, (CFTimeInterval)20, &error);
else
resolutionStarted = CFNetServiceResolve(resolveSvc, &error);


if (resolutionStarted)
{
CFRunLoopRun();
}
else
{
// Something went wrong so lets clean up.
CFNetServiceUnscheduleFromRunLoop(resolveSvc, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
CFNetServiceSetClient(resolveSvc, NULL, NULL);
CFRelease(resolveSvc);
}
}


MyResolveCallback (which never gets called) is declared like this:

void MyResolveCallback(CFNetServiceRef service, CFStreamError* / *error*/, void* info);

I had heard there were differences between CFNetServiceResolve and the newer WithTimeout version. I only added the check for TigerOrLater() and the call to the WithTimeout variant after this stopped working. Oddly, that one always returns false while CFNetServiceResolve returns true. The call to CFRunLoopRun was also added afterwards during my attempts to find out what's going wrong here. Also, it doesn't seem to matter if the given name contains any punctuation or other characters. The code continues to work fine on Panther...

Thanks in advance for any help. I hope someone spots something obvious. I'm at a little bit of a loss :)

Ken

--
Ken Worley, Software Engineer, Tiberius, Inc.
http://www.worleyphoto.com


_______________________________________________ Do not post admin requests to the list. They will be ignored. Bonjour-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/bonjour-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Bonjour-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/bonjour-dev/email@hidden

This email sent to email@hidden
References: 
 >CFNetServiceResolve - callback never gets called (From: Ken Worley <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.