open(withLocalEndpoint:completionHandler:)
Opens the flow, indicating to the system that the caller is ready to start receiving and sending data.
Declaration
func open(withLocalEndpoint localEndpoint: NWHostEndpoint?, completionHandler: @escaping @Sendable ((any Error)?) -> Void)func open(withLocalEndpoint localEndpoint: NWHostEndpoint?) async throwsParameters
- localEndpoint:
An Nwhostendpoint object that contains the address and port to set as the local address and local port of the flow.
The system supplies this information to the app that triggered the creation of this flow in different ways, depending on the networking API the app used. For example, if the app used the Network framework, it gets this information from the Localendpoint property of the current path. If it used BSD Sockets, it gets this information by calling
getsockname.Pass
nilto have the system derive a value based on the address of the current primary physical interface. - completionHandler:
Called when the open operation is complete. This block has no return value and takes the following parameter:
- error
A
nilvalue indicates the flow opened successfully. A non-nilvalue indicates the flow could not be opened. See Neappproxyflowerror Swift.struct for a list of expected error codes.
Discussion
An NEAppProxyFlow object starts out in the unopened state. When the system passes a flow to your app proxy provider by calling handleNewFlow(_:), to need to set up the state necessary to handle the flow’s data, and then call this method.