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


enum NWListener.State



case setup

The listener has been initialized but not started.

case waiting(NWError)

The listener is waiting for a network to become available.

case ready

The listener is running and able to receive incoming connections.

case failed(NWError)

The listener has encountered a fatal error.

case cancelled

The listener has been canceled.

Operator Functions


Conforms To

See Also

Creating Listeners

init(using: NWParameters, on: NWEndpoint.Port)

Initializes a network listener, with an optional local port.

func start(queue: DispatchQueue)

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

var stateUpdateHandler: ((NWListener.State) -> Void)?

A handler that receives listener state updates.

var port: NWEndpoint.Port?

The port on which the listener can accept connections.

func cancel()

Stops listening for inbound connections.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software