<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.5.0 - 10.6.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecHostSetHostingPort",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecHostSetHostingPort"
  },
  "title" : "SecHostSetHostingPort"
}
-->

# SecHostSetHostingPort

Tells code signing services that the calling code will directly respond to hosting inquiries over the given port.

```
OSStatus SecHostSetHostingPort(mach_port_t hostingPort, SecCSFlags flags);
```

## Parameters

`hostingPort`

A Mach message port with send rights. This port is recorded and handed to parties interested in querying the host about its children.

`flags`

Optional flags; see [`SecCSFlags`](/documentation/Security/SecCSFlags) for possible values. Pass [`kSecCSDefaultFlags`](/documentation/Security/SecCSFlags/kSecCSDefaultFlags) for standard behavior.

## Return Value

A result code. See [Code Signing Services Result Codes](/documentation/Security/code-signing-services-result-codes).

## Discussion

If you want to use dynamic hosting mode (see [Guest Code](/documentation/Security/code-signing-services#Guest-Code)), call this function before calling any other code signing services hosting functions. When you call [`SecHostSetHostingPort`](/documentation/Security/SecHostSetHostingPort), the calling code takes direct responsibility for answering questions about its guests using the hosting IPC services. After you call this function, you cannot call the [`SecHostCreateGuest`](/documentation/Security/SecHostCreateGuest), [`SecHostRemoveGuest`](/documentation/Security/SecHostRemoveGuest), or [`SecHostSetGuestStatus`](/documentation/Security/SecHostSetGuestStatus) functions.

The [`SecHostSelectGuest`](/documentation/Security/SecHostSelectGuest) and [`SecHostSelectedGuest`](/documentation/Security/SecHostSelectedGuest) functions work after calling this function.

Once you call this function, the calling code must act in dynamic hosting mode; proxy hosting mode is disabled for the lifetime of the calling code.

Dynamic hosting is useful if you have a large host with many guests that are changing status frequently. In that case, it’s more efficient to only respond to requests for information when they’re made than to call the status update functions ([`SecHostCreateGuest`](/documentation/Security/SecHostCreateGuest), [`SecHostSetGuestStatus`](/documentation/Security/SecHostSetGuestStatus), or [`SecHostRemoveGuest`](/documentation/Security/SecHostRemoveGuest)) every time something changes. However, dynamic hosting mode is not fully supported by high-level API functions at this time. Unless you have extensive knowledge of Mach messaging and have a particular need to manage your guest code dynamically, it is recommended that you use proxy hosting mode.

## See Also

[`SecHostCreateGuest`](/documentation/Security/SecHostCreateGuest)

Creates a new guest and describes its initial properties.



---

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)