May 2003
Intermediate to advanced
566 pages
27h 29m
English
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.
// Get the NSHost object for the current hostNSHost *host = [NSHost currentHost];// Get the name of a hostNSString *name = [host name];// Get the address of a host; returns "xxx.xxx.xxx.xxx" stringNSString *addr = [host address];// Other ways to create a host objectNSHost *host = [NSHost hostWithAddress:@"www.oreilly.com"]; NSHost *host = [NSHost hostWithName:@"209.204.146.22"];// If a host has multiple names or address, use the followingNSArray *names = [host names]; NSArray *addrs = [host addresses];
Read now
Unlock full access