<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/xpc_set_event_stream_handler(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "c:@F@xpc_set_event_stream_handler"
  },
  "title" : "xpc_set_event_stream_handler(_:_:_:)"
}
-->

# xpc_set_event_stream_handler(_:_:_:)

Sets the event handler to invoke when receiving streamed events.

```
func xpc_set_event_stream_handler(_ stream: UnsafePointer<CChar>, _ targetq: dispatch_queue_t?, _ handler: @escaping @Sendable (xpc_object_t) -> Void)
```

## Parameters

`stream`

The name of the event stream for which this handler will be invoked.

`targetq`

The GCD queue to which the event handler block will be submitted. This parameter may be NULL, in which case the connection’s target queue will be the default target queue of `libdispatch`, defined as `DISPATCH_TARGET_QUEUE_DEFAULT`.

`handler`

The event handler block. The event which this block receives as its first parameter will always be a dictionary which contains the [`XPC_EVENT_KEY_NAME`](/documentation/XPC/XPC_EVENT_KEY_NAME-swift.var) key. The value for this key will be a string whose value is the name assigned to the XPC event specified in the `launchd.plist`. Future keys may be added to this dictionary.

## Discussion

Multiple calls to this function for the same event stream will result in undefined behavior.

---

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)