<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Network",
  "identifier" : "/documentation/Network/nw_listener_t",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "Network"
    ],
    "preciseIdentifier" : "c:@T@nw_listener_t"
  },
  "title" : "nw_listener_t"
}
-->

# nw_listener_t

An object you use to listen for incoming network connections.

```
typealias nw_listener_t = any OS_nw_listener
```

## Topics

### Creating Listeners

[`nw_listener_create(_:)`](/documentation/Network/nw_listener_create(_:))

Initializes a network listener, which will select a random port.

[`nw_listener_create_with_port(_:_:)`](/documentation/Network/nw_listener_create_with_port(_:_:))

Initializes a network listener with a specified local port.

[`nw_listener_create_with_connection(_:_:)`](/documentation/Network/nw_listener_create_with_connection(_:_:))

Initializes a network listener to receive new streams on a multiplexed connection.

[`nw_listener_set_queue(_:_:)`](/documentation/Network/nw_listener_set_queue(_:_:))

Sets the queue on which all listener events are delivered.

[`nw_listener_start(_:)`](/documentation/Network/nw_listener_start(_:))

Registers for listening for inbound connections.

[`nw_listener_get_port(_:)`](/documentation/Network/nw_listener_get_port(_:))

The port on which the listener can accept connections.

[`nw_listener_cancel(_:)`](/documentation/Network/nw_listener_cancel(_:))

Stops listening for inbound connections.

### Receiving Connections

[`nw_listener_set_new_connection_handler(_:_:)`](/documentation/Network/nw_listener_set_new_connection_handler(_:_:))

Sets a handler that receives inbound connections.

[`nw_listener_new_connection_handler_t`](/documentation/Network/nw_listener_new_connection_handler_t)

A handler that delivers inbound connections.

[`nw_listener_set_new_connection_limit(_:_:)`](/documentation/Network/nw_listener_set_new_connection_limit(_:_:))

Resets the number of inbound connections to deliver before rejecting connections.

[`nw_listener_get_new_connection_limit(_:)`](/documentation/Network/nw_listener_get_new_connection_limit(_:))

Checks the remaining number of inbound connections to deliver before rejecting connections.

[`NW_LISTENER_INFINITE_CONNECTION_LIMIT`](/documentation/Network/NW_LISTENER_INFINITE_CONNECTION_LIMIT)

A static value that indicates that inbound connections should not be limited.

### Advertising Bonjour Services

  <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/NSBonjourServices>

  <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/NSLocalNetworkUsageDescription>

[`nw_listener_set_advertise_descriptor(_:_:)`](/documentation/Network/nw_listener_set_advertise_descriptor(_:_:))

Sets a Bonjour service that advertises the listener on the local network.

[`nw_advertise_descriptor_t`](/documentation/Network/nw_advertise_descriptor_t)

A description used to advertise the Bonjour service that a listener provides.

[`nw_listener_set_advertised_endpoint_changed_handler(_:_:)`](/documentation/Network/nw_listener_set_advertised_endpoint_changed_handler(_:_:))

Sets a handler that receives updates for the service endpoint being advertised.

[`nw_listener_advertised_endpoint_changed_handler_t`](/documentation/Network/nw_listener_advertised_endpoint_changed_handler_t)

A handler that indicates changes to the service endpoints being advertised as they are added and removed.

### Handling State Updates

[`nw_listener_set_state_changed_handler(_:_:)`](/documentation/Network/nw_listener_set_state_changed_handler(_:_:))

Sets a handler to receive listener state updates.

[`nw_listener_state_changed_handler_t`](/documentation/Network/nw_listener_state_changed_handler_t)

A handler that delivers listener state updates with associated errors.

[`nw_listener_state_t`](/documentation/Network/nw_listener_state_t)

States indicating whether a listener is able to accept incoming connections.



---

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)