6.1 Hosts

NSHost provides services that find host names from addresses and addresses from host names. NSHost relies on the network services available to the operating system, such as LDAP, NetInfo, or the Domain Name Service (DNS). Example 6-1 shows how to use NSHost.

Example 6-1. Using NSHost
// Get the NSHost object for the current host
NSHost *host = [NSHost currentHost];

// Get the name of a host
NSString *name = [host name];

// Get the address of a host; returns "xxx.xxx.xxx.xxx" string
NSString *addr = [host address];

// Other ways to create a host object
NSHost *host = [NSHost hostWithAddress:@"www.oreilly.com"];
NSHost *host = [NSHost hostWithName:@"209.204.146.22"];

// If a host has multiple names or address, use the following
NSArray *names = [host names];
NSArray *addrs = [host addresses];


    Part II: API Quick Reference