---
title: "portForName:host:"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmessageportnameserver/portforname:host:"
---

# portForName:host:

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

## Declaration

```occ
- (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

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

## See Also

### Getting Ports By Name

- [portForName:](foundation/nsmessageportnameserver/portforname:.md)
