<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 12.0.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Network",
  "identifier" : "/documentation/Network/NWListener",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Network"
    ],
    "preciseIdentifier" : "s:7Network10NWListenerC"
  },
  "title" : "NWListener"
}
-->

# NWListener

An object you use to listen for incoming network connections.

```
final class NWListener
```

## Topics

### Creating Listeners

[`init(using:on:)`](/documentation/Network/NWListener/init(using:on:))

Initializes a network listener, with an optional local port.

[`start(queue:)`](/documentation/Network/NWListener/start(queue:))

Registers for listening, and sets the queue on which all listener events are delivered.

[`stateUpdateHandler`](/documentation/Network/NWListener/stateUpdateHandler)

A handler that receives listener state updates.

[`State`](/documentation/Network/NWListener/State-swift.enum)

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

[`port`](/documentation/Network/NWListener/port)

The port on which the listener can accept connections.

[`cancel()`](/documentation/Network/NWListener/cancel())

Stops listening for inbound connections.

### Receiving Connections

[`newConnectionHandler`](/documentation/Network/NWListener/newConnectionHandler)

A handler that receives inbound connections.

[`newConnectionLimit`](/documentation/Network/NWListener/newConnectionLimit)

The remaining number of inbound connections to deliver before rejecting connections.

[`InfiniteConnectionLimit`](/documentation/Network/NWListener/InfiniteConnectionLimit)

A static value to indicate 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>

[`service`](/documentation/Network/NWListener/service-swift.property)

A Bonjour service that advertises the listener on the local network.

[`Service`](/documentation/Network/NWListener/Service-swift.struct)

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

[`serviceRegistrationUpdateHandler`](/documentation/Network/NWListener/serviceRegistrationUpdateHandler)

A handler that receives updates for the service endpoint being advertised.

[`ServiceRegistrationChange`](/documentation/Network/NWListener/ServiceRegistrationChange)

Changes to how a network listener’s service is advertised.

### Inspecting Listeners

[`parameters`](/documentation/Network/NWListener/parameters)

The parameters used to initialize the listener.

[`queue`](/documentation/Network/NWListener/queue)

The queue on which listener events are delivered.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)