<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/XPCListener/init(targetQueue:options:incomingSessionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "s:3XPC11XPCListenerC11targetQueue7options22incomingSessionHandlerACSo17OS_dispatch_queueCSg_AC21InitializationOptionsVAC08IncomingG7RequestC8DecisionVAMctcfc"
  },
  "title" : "init(targetQueue:options:incomingSessionHandler:)"
}
-->

# init(targetQueue:options:incomingSessionHandler:)

Creates an anonymous listener

```
@preconcurrency init(targetQueue: DispatchQueue? = nil, options: XPCListener.InitializationOptions = .none, incomingSessionHandler: @escaping @Sendable (XPCListener.IncomingSessionRequest) -> XPCListener.IncomingSessionRequest.Decision)
```

## Return Value

Returns a new listener object. The returned listener is activated by default
and will begin receiving incoming session requests

## Discussion

- targetQueue: The GCD queue onto which listener events will be submitted.
  This may be a concurrent queue. This parameter is optional, if the target queue is
  not specified the target queue will be libdispatch’s default target queue, defined as
  `DISPATCH_TARGET_QUEUE_DEFAULT`.
- options: Additional attributes to create the listener
- incomingSessionHandler: The handler block to be called when a peer
  is attempting to establish a connection with this listener. The incoming session
  handler is mandatory.

---

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)