Type Alias


An object you use to listen for incoming network connections.


typealias nw_listener_t = OS_nw_listener


Creating Listeners

func nw_listener_create(nw_parameters_t) -> nw_listener_t?

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

func nw_listener_create_with_connection(nw_connection_t, nw_parameters_t) -> nw_listener_t?

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

func nw_listener_set_queue(nw_listener_t, DispatchQueue)

Sets the queue on which all listener events are delivered.

func nw_listener_start(nw_listener_t)

Registers for listening for inbound connections.

func nw_listener_get_port(nw_listener_t) -> UInt16

The port on which the listener can accept connections.

func nw_listener_cancel(nw_listener_t)

Stops listening for inbound connections.

Receiving Connections

typealias nw_listener_new_connection_handler_t

A handler that delivers inbound connections.

func nw_listener_set_new_connection_limit(nw_listener_t, UInt32)

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

func nw_listener_get_new_connection_limit(nw_listener_t) -> UInt32

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


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

Advertising Bonjour Services

func nw_listener_set_advertise_descriptor(nw_listener_t, nw_advertise_descriptor_t?)

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

typealias nw_advertise_descriptor_t

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

typealias 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

typealias nw_listener_state_changed_handler_t

A handler that delivers listener state updates with associated errors.

struct nw_listener_state_t

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