diff -r 732576fa8a0d -r 1d6924779df7 Bonjour/MYAddressLookup.m --- a/Bonjour/MYAddressLookup.m Mon Apr 27 09:03:56 2009 -0700 +++ b/Bonjour/MYAddressLookup.m Wed Apr 29 13:29:31 2009 -0700 @@ -60,17 +60,17 @@ sockaddr: sockaddr port: _port]; if (address) { - if (flags & kDNSServiceFlagsAdd) + if (flags & kDNSServiceFlagsAdd) { + LogTo(DNS,@"%@ got %@ [TTL = %u]", self, address, ttl); [_addresses addObject: address]; - else + } else { + LogTo(DNS,@"%@ lost %@ [TTL = %u]", self, address, ttl); [_addresses removeObject: address]; + } [address release]; } _expires = CFAbsoluteTimeGetCurrent() + ttl; - - if (!(flags & kDNSServiceFlagsMoreComing)) - LogTo(DNS,@"Got addresses of %@: %@ [TTL = %u]", self, _addresses, ttl); } @@ -91,17 +91,17 @@ else [lookup priv_resolvedAddress: address ttl: ttl flags: flags]; }catchAndReport(@"MYDNSLookup query callback"); + [lookup gotResponse: errorCode]; } -- (DNSServiceRef) createServiceRef { +- (DNSServiceErrorType) createServiceRef: (DNSServiceRef*)sdRefPtr { [_addresses removeAllObjects]; - DNSServiceRef serviceRef = NULL; - self.error = DNSServiceGetAddrInfo(&serviceRef, 0, - _interfaceIndex, 0, - _hostname.UTF8String, - &lookupCallback, self); - return serviceRef; + return DNSServiceGetAddrInfo(sdRefPtr, + kDNSServiceFlagsShareConnection, + _interfaceIndex, 0, + _hostname.UTF8String, + &lookupCallback, self); } @@ -120,3 +120,26 @@ [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 10]]; [lookup release]; } + + +/* + 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. + */