- Inherits from:
- NSObject
- Conforms to:
- NSObject
- (NSObject)
Declared in:
- Foundation/NSHost.h
An NSHost object holds network name and address information for a host. You use this class to get the current host's name and address and to look up other hosts by name or by address.
To create an NSHost, use the currentHost, hostWithAddress:, or hostWithName: class methods (don't use alloc and init). These methods use available network administration services (such as NetInfo or the Domain Name Service) to discover all names and addresses for the host requested. They don't attempt to contact the host itself, however. This avoids untimely delays due to a host being unavailable, but it may result in incomplete information about the host.
An NSHost instance contains all of the network addresses and
names discovered for a given host by the network administration
services. Each NSHost typically contains one unique address, but
it may have more than one name. If an NSHost has more than one name,
the additional names are variations on the same name, typically
the basic host name plus the fully qualified domain name. For example, with
a host name "sales
"
in the domain "anycorp.com
",
an NSHost can hold both the names "sales
"
and "sales.anycorp.com
".
The NSHost class maintains a cache of previously created instances so that requests for an existing NSHost return that object instead of creating a new one. Use the setHostCacheEnabled: method to turn the cache off, forcing lookup of hosts as they're requested. You can also use the flushHostCache method to clear the cache of its entries so that subsequent requests look up the host information and create new instances.
- Creating an NSHost
- + currentHost
- + hostWithAddress:
- + hostWithName:
- Getting host names and addresses
- - address
- - addresses
- - name
- - names
- Comparing instances
- - isEqualToHost:
- Controlling the cache
- + setHostCacheEnabled:
- + isHostCacheEnabled
- + flushHostCache
+ (NSHost *)currentHost
See Also: + hostWithAddress:, + hostWithName:
+ (void)flushHostCache
See Also: + isHostCacheEnabled, + setHostCacheEnabled:
+ (NSHost *)hostWithAddress:(NSString
*)address
127.0.0.1
".See Also: + hostWithName:, + setHostCacheEnabled:
+ (NSHost *)hostWithName:(NSString
*)name
sales
",
or a fully qualified domain name, such as "sales.anycorp.com
".See Also: + hostWithAddress:, + setHostCacheEnabled:
+ (BOOL)isHostCacheEnabled
See Also: + setHostCacheEnabled:, + flushHostCache
+ (void)setHostCacheEnabled:(BOOL)flag
This method doesn't flush the cache. If you turn caching off and then back on, new requests for hosts use what was in the cache at the time caching was turned off. However, NSHost instances created while caching is turned off aren't entered into the cache.
See Also: + isHostCacheEnabled, + flushHostCache
- (NSString *)address
192.42.172.1
".See Also: - addresses, - name
- (NSArray *)addresses
192.42.172.1
".- (BOOL)isEqualToHost:(NSHost
*)aHost
See Also: - addresses
- (NSString *)name
sales.anycorp.com
"
or a simple host name such as "sales
".- (NSArray *)names
sales.anycorp.com
",
or simple host names, such as "sales
".See Also: - addresses, - name