jens@28: // jens@28: // MYAddressLookup.h jens@28: // MYNetwork jens@28: // jens@28: // Created by Jens Alfke on 4/24/09. jens@28: // Copyright 2009 Jens Alfke. All rights reserved. jens@28: // jens@28: jens@28: #import "MYDNSService.h" jens@50: @class MYBonjourService; jens@28: jens@28: jens@28: /** An asynchronous DNS address lookup. Supports both Bonjour services and traditional hostnames. */ jens@28: @interface MYAddressLookup : MYDNSService jens@28: { jens@50: MYBonjourService *_service; jens@28: NSString *_hostname; jens@28: UInt16 _interfaceIndex; jens@28: NSMutableSet *_addresses; jens@28: UInt16 _port; jens@28: CFAbsoluteTime _expires; jens@28: } jens@28: jens@31: /** Initializes the lookup with a DNS hostname. jens@31: (If you've got a Bonjour service already, as a MYBonjourService object, it's more convenient jens@31: to access its addressLookup property instead of creating your own instance.) */ jens@28: - (id) initWithHostname: (NSString*)hostname; jens@28: jens@50: @property (readonly, copy) NSString *hostname; jens@50: jens@28: /** The port number; this will be copied into the resulting IPAddress objects. jens@28: Defaults to zero, but you can set it before calling -start. */ jens@28: @property UInt16 port; jens@28: jens@31: /** The index of the network interface to use, or zero (the default) for any interface. jens@31: You usually don't need to set this. */ jens@28: @property UInt16 interfaceIndex; jens@28: jens@28: /** The resulting address(es) of the host, as HostAddress objects. */ jens@28: @property (readonly) NSSet *addresses; jens@28: jens@28: /** How much longer the addresses will remain valid. jens@28: If the value is zero, the addresses are no longer valid, and you should instead jens@28: call -start again and wait for the 'addresses' property to update. jens@28: If you set the service to continuous mode, addresses will never expire since the jens@28: query will continue to update them. */ jens@28: @property (readonly) NSTimeInterval timeToLive; jens@28: jens@50: jens@50: //internal: jens@50: - (id) _initWithBonjourService: (MYBonjourService*)service; jens@50: - (void) _serviceGotResponse; jens@50: jens@28: @end