1.1 --- a/Bonjour/MYAddressLookup.m Mon Apr 27 09:03:56 2009 -0700
1.2 +++ b/Bonjour/MYAddressLookup.m Mon May 04 23:10:51 2009 -0700
1.3 @@ -60,17 +60,17 @@
1.4 sockaddr: sockaddr
1.5 port: _port];
1.6 if (address) {
1.7 - if (flags & kDNSServiceFlagsAdd)
1.8 + if (flags & kDNSServiceFlagsAdd) {
1.9 + LogTo(DNS,@"%@ got %@ [TTL = %u]", self, address, ttl);
1.10 [_addresses addObject: address];
1.11 - else
1.12 + } else {
1.13 + LogTo(DNS,@"%@ lost %@ [TTL = %u]", self, address, ttl);
1.14 [_addresses removeObject: address];
1.15 + }
1.16 [address release];
1.17 }
1.18
1.19 _expires = CFAbsoluteTimeGetCurrent() + ttl;
1.20 -
1.21 - if (!(flags & kDNSServiceFlagsMoreComing))
1.22 - LogTo(DNS,@"Got addresses of %@: %@ [TTL = %u]", self, _addresses, ttl);
1.23 }
1.24
1.25
1.26 @@ -91,17 +91,17 @@
1.27 else
1.28 [lookup priv_resolvedAddress: address ttl: ttl flags: flags];
1.29 }catchAndReport(@"MYDNSLookup query callback");
1.30 + [lookup gotResponse: errorCode];
1.31 }
1.32
1.33
1.34 -- (DNSServiceRef) createServiceRef {
1.35 +- (DNSServiceErrorType) createServiceRef: (DNSServiceRef*)sdRefPtr {
1.36 [_addresses removeAllObjects];
1.37 - DNSServiceRef serviceRef = NULL;
1.38 - self.error = DNSServiceGetAddrInfo(&serviceRef, 0,
1.39 - _interfaceIndex, 0,
1.40 - _hostname.UTF8String,
1.41 - &lookupCallback, self);
1.42 - return serviceRef;
1.43 + return DNSServiceGetAddrInfo(sdRefPtr,
1.44 + kDNSServiceFlagsShareConnection,
1.45 + _interfaceIndex, 0,
1.46 + _hostname.UTF8String,
1.47 + &lookupCallback, self);
1.48 }
1.49
1.50
1.51 @@ -120,3 +120,26 @@
1.52 [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 10]];
1.53 [lookup release];
1.54 }
1.55 +
1.56 +
1.57 +/*
1.58 + Copyright (c) 2009, Jens Alfke <jens@mooseyard.com>. All rights reserved.
1.59 +
1.60 + Redistribution and use in source and binary forms, with or without modification, are permitted
1.61 + provided that the following conditions are met:
1.62 +
1.63 + * Redistributions of source code must retain the above copyright notice, this list of conditions
1.64 + and the following disclaimer.
1.65 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
1.66 + and the following disclaimer in the documentation and/or other materials provided with the
1.67 + distribution.
1.68 +
1.69 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
1.70 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
1.71 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
1.72 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1.73 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1.74 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1.75 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
1.76 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.77 + */