<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.13.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMessagePortNameServer/portForName:host:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMessagePortNameServer(im)portForName:host:"
  },
  "title" : "portForName:host:"
}
-->

# portForName:host:

Returns the `NSPort` object registered under a given name on the local host.

```
- (NSPort *) portForName:(NSString *) name host:(NSString *) host;
```

## Parameters

`name`

The port name.

`host`

The host name. Because `NSMessagePortNameServer` is a local-only server, `host` must be the empty string or `nil`.

## Return Value

The `NSPort` object registered under a given name on the local host. Returns `nil` if a port named `name` does not exist.

---

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)