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

# connectionWithRegisteredName:host:

Returns the `NSConnection` object whose send port links it to the `NSConnection` object registered with the default `NSPortNameServer` under a given name on a given host.

```
+ (instancetype) connectionWithRegisteredName:(NSString *) name host:(NSString *) hostName;
```

## Parameters

`name`

The name of an `NSConnection` object.

`hostName`

The name of the host. The domain name `hostName` is an Internet domain name (for example, “`sales.anycorp.com`”). If `hostName` is `nil` or empty, then only the local host is searched for the named `NSConnection` object.

## Return Value

The `NSConnection` object whose send port links it to the `NSConnection` object registered with the default `NSPortNameServer` under `name` on the host named `hostName`. Returns `nil` if no `NSConnection` object can be found for `name` and `hostName`. The returned `NSConnection` object is a child of the default `NSConnection` object for the current thread (that is, it shares the default `NSConnection` object’s receive port).

## Discussion

To get the object vended by the `NSConnection` object, use the [`rootProxy`](/documentation/Foundation/NSConnection/rootProxy) instance method. The [`rootProxyForConnectionWithRegisteredName:host:`](/documentation/Foundation/NSConnection/rootProxyForConnectionWithRegisteredName:host:) class method immediately returns this object.

## See Also

[`+ (NSConnection *) defaultConnection;`](/documentation/Foundation/NSConnection/defaultConnection)

Returns the default `NSConnection` object for the current thread.



---

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)