<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/launch_activate_socket",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "c:@F@launch_activate_socket"
  },
  "title" : "launch_activate_socket"
}
-->

# launch_activate_socket

Retrieves the file descriptors for sockets in the process’s `launchd` property list.

```
extern int launch_activate_socket(const char *name, int **fds, size_t *cnt);
```

## Parameters

`name`

The name of the socket entry in the service’s Sockets dictionary.

`fds`

On return, this parameter is populated with an array of file descriptors. One socket can have many descriptors associated with it depending on the characteristics of the network interfaces on the system. The descriptors in this array are the results of calling `getaddrinfo(3)` with the parameters described in `launchd.plist`. The caller is responsible for calling `free(3)` on the returned pointer.

`cnt`

The number of file descriptor entries in the returned array.

## Return Value

On success, `0` is returned. Otherwise, an appropriate POSIX-domain is returned.

## Discussion

The possible error codes are:

- `ENOENT` — There was no socket of the specified name owned by the caller.
- `ESRCH` — The caller isn’t a process managed by launchd.
- `EALREADY` — The socket has already been activated by the caller.

---

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)