A representation of an individual host on the network.
- macOS 10.0+
Host class provides methods to access the network name and address information for a host. Instances of the
Host class represent individual hosts on a network. Use
Host objects to get the current host’s names and addresses and to look up other hosts by name or by address.
To create an
Host object, use the
init(name:) class methods (don’t use
init). These methods use available network administration services to discover all names and addresses for the host requested. They don’t attempt to contact the host itself, however. This approach avoids untimely delays due to a host being unavailable, but it may result in incomplete information about the host.
Host object contains all of the network addresses and names discovered for a given host by the network administration services. Each
Host object may contain several addresses and have more than one name. If an
Host object 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
Host object can hold both the names
Host methods are thread-safe.