diff -r 732576fa8a0d -r dd637bdd214e Bonjour/MYBonjourQuery.m --- a/Bonjour/MYBonjourQuery.m Mon Apr 27 09:03:56 2009 -0700 +++ b/Bonjour/MYBonjourQuery.m Mon Jul 20 14:50:49 2009 -0700 @@ -105,31 +105,55 @@ uint32_t ttl, void *context) { + MYBonjourQuery *query = context; @try{ //LogTo(Bonjour, @"queryCallback for %@ (err=%i)", context,errorCode); - if (errorCode) - [(MYBonjourQuery*)context setError: errorCode]; - else - [(MYBonjourQuery*)context priv_gotRecordBytes: rdata - length: rdlen - type: rrtype - ttl: ttl - flags: flags]; + if (!errorCode) + [query priv_gotRecordBytes: rdata + length: rdlen + type: rrtype + ttl: ttl + flags: flags]; }catchAndReport(@"MYBonjourResolver query callback"); + [query gotResponse: errorCode]; } -- (DNSServiceRef) createServiceRef { - DNSServiceRef serviceRef = NULL; +- (DNSServiceErrorType) createServiceRef: (DNSServiceRef*)sdRefPtr { const char *fullName = _bonjourService.fullName.UTF8String; if (fullName) - self.error = DNSServiceQueryRecord(&serviceRef, 0, - _bonjourService.interfaceIndex, - fullName, - _recordType, kDNSServiceClass_IN, - &queryCallback, self); - return serviceRef; + return DNSServiceQueryRecord(sdRefPtr, + kDNSServiceFlagsShareConnection, + _bonjourService.interfaceIndex, + fullName, + _recordType, kDNSServiceClass_IN, + &queryCallback, self); + else + return kDNSServiceErr_NoSuchName; } @end + + +/* + Copyright (c) 2009, Jens Alfke . All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */