<!--
{
  "availability" : [
    "macOS: 10.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Host",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSHost"
  },
  "title" : "Host"
}
-->

# Host

A representation of an individual host on the network.

```
class Host
```

## Overview

The [`Host`](/documentation/Foundation/Host) class provides methods to access the network name and address information for a host. Instances of the [`Host`](/documentation/Foundation/Host) class represent individual *hosts* on a network. Use [`Host`](/documentation/Foundation/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`](/documentation/Foundation/Host) object, use the [`current()`](/documentation/Foundation/Host/current()), [`init(address:)`](/documentation/Foundation/Host/init(address:)), or [`init(name:)`](/documentation/Foundation/Host/init(name:)) class methods (don’t use `alloc` and `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.

An [`Host`](/documentation/Foundation/Host) object contains all of the network addresses and names discovered for a given host by the network administration services. Each [`Host`](/documentation/Foundation/Host) object may contain several addresses and have more than one name. If an [`Host`](/documentation/Foundation/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 `"anycorp.com"`, an [`Host`](/documentation/Foundation/Host) object can hold both the names `"sales"` and `"sales.anycorp.com"`.

[`Host`](/documentation/Foundation/Host) methods are thread-safe.

## Topics

### Creating Hosts

[`+  currentHost`](/documentation/Foundation/Host/current())

Returns an `NSHost` object representing the host the process is running on.

[`+  hostWithAddress:`](/documentation/Foundation/Host/init(address:))

Returns the `NSHost` with the Internet address `address`.

[`+  hostWithName:`](/documentation/Foundation/Host/init(name:))

Returns a host with a specific name.

### Getting Host Information

[`address`](/documentation/Foundation/Host/address)

Returns one of the network addresses of the receiver.

[`addresses`](/documentation/Foundation/Host/addresses)

Returns all the network addresses of the receiver.

[`name`](/documentation/Foundation/Host/name)

Returns one of the hostnames of the receiver.

[`localizedName`](/documentation/Foundation/Host/localizedName)

Returns the name used as by default when publishing `NSNetServices`.

[`names`](/documentation/Foundation/Host/names)

Returns all the hostnames of the receiver.

### Comparing Hosts

[`-  isEqualToHost:`](/documentation/Foundation/Host/isEqual(to:))

Indicates whether the receiver represents the same host as another `NSHost` object.

### Managing the Host Cache

[`+  isHostCacheEnabled`](/documentation/Foundation/NSHost/isHostCacheEnabled)

Indicates whether caching is turned on or off.

[`+  setHostCacheEnabled:`](/documentation/Foundation/NSHost/setHostCacheEnabled:)

Specifies whether the receiver is to cache instances as it creates them to avoid creating duplicate instances.

[`+  flushHostCache`](/documentation/Foundation/NSHost/flushHostCache)

Releases the cache of existing `NSHost` objects so subsequent requests for `NSHost` objects create new ones.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)