parameters
TypeScriptget parameters(): NWParametersSwift declarationfinal let parameters: NWParametersNWParameters used to create the listener
class · iOS 12.0+ · SDK 27.1
final class NWListenerAn NWListener is an object that is able to receive incoming NWConnection objects by binding to a local endpoint. A listener will accept connections based on the protocols defined in its stack. For transport listeners (such as TCP and UDP), accepted connections will represent new local and remote address and port tuples. For listeners that include higher-level protocols that support multiplexing, accepted connections will represent multiplexed streams on a new or existing transport binding.
get parameters(): NWParametersSwift declarationfinal let parameters: NWParametersNWParameters used to create the listener
get debugDescription(): stringSwift declarationfinal var debugDescription: String { get }A textual representation of this instance, suitable for debugging. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(reflecting:)` initializer. This initializer works with any type, and uses the custom `debugDescription` property for types that conform to `CustomDebugStringConvertible`: struct Point: CustomDebugStringConvertible { let x: Int, y: Int var debugDescription: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(reflecting: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `debugDescription` property.
static initApplicationServiceUsing(name: string, parameters?: NWParameters): NWListenerSwift declarationconvenience init(applicationService name: String, using parameters: NWParameters = .applicationService) throwsCreate a listener that advertises an application service. - Parameter applicationService: The name of the application service to advertise. - Parameter using: The parameters to use for the listener.
get newConnectionLimit(): numberSwift declarationfinal var newConnectionLimit: Int { get set }Configure the listener's new connection limit. Use the value NWListener.InfiniteConnectionLimit to disable connection limits. If the value is not NWListener.InfiniteConnectionLimit, the value will be decremented by 1 every time a new connection is received. When the value reaches 0, the new connection handler will no longer be invoked until the the limit is increased. newConnectionLimit >= UInt32.max will be treated as infinite.
set newConnectionLimit(value: number)Swift declarationfinal var newConnectionLimit: Int { get set }Configure the listener's new connection limit. Use the value NWListener.InfiniteConnectionLimit to disable connection limits. If the value is not NWListener.InfiniteConnectionLimit, the value will be decremented by 1 every time a new connection is received. When the value reaches 0, the new connection handler will no longer be invoked until the the limit is increased. newConnectionLimit >= UInt32.max will be treated as infinite.
get stateUpdateHandler(): (((arg0: NWListener_State) => Promise<void>)) | nullSwift declaration@preconcurrency final var stateUpdateHandler: (@Sendable (NWListener.State) -> Void)? { get set }Set a block to be called when the listener's state changes, which may be called multiple times until the listener is cancelled.
set stateUpdateHandler(value: (((arg0: NWListener_State) => void)) | null)Swift declaration@preconcurrency final var stateUpdateHandler: (@Sendable (NWListener.State) -> Void)? { get set }Set a block to be called when the listener's state changes, which may be called multiple times until the listener is cancelled.
get newConnectionHandler(): (((arg0: NWConnection) => Promise<void>)) | nullSwift declaration@preconcurrency final var newConnectionHandler: (@Sendable (NWConnection) -> Void)? { get set }Block to be called for new inbound connections
set newConnectionHandler(value: (((arg0: NWConnection) => void)) | null)Swift declaration@preconcurrency final var newConnectionHandler: (@Sendable (NWConnection) -> Void)? { get set }Block to be called for new inbound connections
static get InfiniteConnectionLimit(): numberSwift declarationstatic let InfiniteConnectionLimit: IntStatic value to make the listener's new connection limit unbounded.
get newConnectionGroupHandler(): (((arg0: NWConnectionGroup) => Promise<void>)) | nullSwift declaration@preconcurrency final var newConnectionGroupHandler: (@Sendable (NWConnectionGroup) -> Void)? { get set }Block to be called for new connection groups
set newConnectionGroupHandler(value: (((arg0: NWConnectionGroup) => void)) | null)Swift declaration@preconcurrency final var newConnectionGroupHandler: (@Sendable (NWConnectionGroup) -> Void)? { get set }Block to be called for new connection groups
get serviceRegistrationUpdateHandler(): (((arg0: NWListener_ServiceRegistrationChange) => Promise<void>)) | nullSwift declaration@preconcurrency final var serviceRegistrationUpdateHandler: (@Sendable (NWListener.ServiceRegistrationChange) -> Void)? { get set }Set a block to be called when the listener has added or removed a registered service. This may be called multiple times until the listener is cancelled.
set serviceRegistrationUpdateHandler(value: (((arg0: NWListener_ServiceRegistrationChange) => void)) | null)Swift declaration@preconcurrency final var serviceRegistrationUpdateHandler: (@Sendable (NWListener.ServiceRegistrationChange) -> Void)? { get set }Set a block to be called when the listener has added or removed a registered service. This may be called multiple times until the listener is cancelled.
get port(): (NWEndpoint_Port) | nullSwift declarationfinal var port: NWEndpoint.Port? { get }The current port the listener is bound to, if any. The port is only valid when the listener is in the ready state.
get queue(): (_Dispatch_DispatchQueue) | nullSwift declarationfinal var queue: DispatchQueue? { get }Get queue used for delivering block handlers, such as stateUpdateHandler, serviceRegistrationUpdateHandler, and newConnectionHandler. If the listener has not yet been started, the queue will be nil. Once the listener has been started, the queue will be non-nil.
start(queue: _Dispatch_DispatchQueue): voidSwift declarationfinal func start(queue: DispatchQueue)Start the listener and provide a queue on which callback handlers will be executed. When the listener state moves to ready, the listener is registered with the system and can receive incoming connections. Start should only be called once on a listener, and multiple calls to start will be ignored.
get state(): NWListener_StateSwift declarationfinal var state: NWListener.State { get }The current state of the listener
static initUsingOn(using: NWParameters, on?: NWEndpoint_Port): NWListenerSwift declarationinit(using: NWParameters, on: NWEndpoint.Port = .any) throwsCreates a networking listener. The listener will be assigned a random port to listen on unless otherwise specified. - Parameter using: The parameters to use for the listener, which include the protocols to use for the listener. The parameters requiredLocalEndpoint may be used to specify the local address and port to listen on. - Parameter on: The port to listen on. Defaults to .any which will cause a random unused port to be assigned. Specifying a port that is already in use will cause the listener to fail after starting. - Returns: Returns a listener object that may be set up and started or throws an error if the parameters are not compatible with the provided port.
cancel(): voidSwift declarationfinal func cancel()Cancel the listener. The cancel is asynchronous and the state will eventually transition to cancelled. Subsequent calls to cancel are ignored.
static initServiceUsing(service: NWListener_Service, parameters: NWParameters): NWListenerSwift declarationconvenience init(service: NWListener.Service, using parameters: NWParameters) throwsCreate a listener that advertises a service. - Parameter service: The service to advertise. - Parameter using: The parameters to use for the listener.
get service(): (NWListener_Service) | nullSwift declarationfinal var service: NWListener.Service? { get set }Optional Bonjour service to advertise with the listener May be modified on the fly to update the TXT record or change the advertised service.
set service(value: (NWListener_Service) | null)Swift declarationfinal var service: NWListener.Service? { get set }Optional Bonjour service to advertise with the listener May be modified on the fly to update the TXT record or change the advertised service.
No declarations were skipped in this snapshot.