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

# NSPortNameServer

An object-oriented interface to the port registration service used by the distributed objects system.

```
@interface NSPortNameServer : NSObject
```

## Overview

[`NSConnection`](/documentation/Foundation/NSConnection) objects use this interface to contact each other and to distribute objects over the network; you should rarely need to interact directly with an [`NSPortNameServer`](/documentation/Foundation/NSPortNameServer).

You get an [`NSPortNameServer`](/documentation/Foundation/NSPortNameServer) object by using the [`systemDefaultPortNameServer`](/documentation/Foundation/NSPortNameServer/systemDefaultPortNameServer) class method—never allocate and initialize an instance directly. With the default server object you can register an [`Port`](/documentation/Foundation/Port) object under a given name, making it available on the network, and also unregister it so that it can’t be looked up (although other applications that have already looked up the [`Port`](/documentation/Foundation/Port) object  can still use it until it becomes invalid). See the [`Port`](/documentation/Foundation/Port) class specification for more information.

## Topics

### Getting the Server Object

[`systemDefaultPortNameServer`](/documentation/Foundation/NSPortNameServer/systemDefaultPortNameServer)

Returns the single instance of `NSPortNameServer` for the application.

### Looking up Ports

[`portForName:`](/documentation/Foundation/NSPortNameServer/portForName:)

Looks up and returns the port registered under the specified name on the local host.

[`portForName:host:`](/documentation/Foundation/NSPortNameServer/portForName:host:)

Looks up and returns the port registered under the specified name on a specified host.

### Registering Ports

[`registerPort:name:`](/documentation/Foundation/NSPortNameServer/registerPort:name:)

Makes a given port available on the network under a specified name.

[`removePortForName:`](/documentation/Foundation/NSPortNameServer/removePortForName:)

Unregisters the port for a given name on the local host.



---

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)