<!--
{
  "availability" : [
    "iOS: 9.0.0 - 18.0.0",
    "iPadOS: 9.0.0 - 18.0.0",
    "macCatalyst: 13.1.0 - 18.0.0",
    "macOS: 10.11.0 - 15.0.0",
    "visionOS: 1.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NEAppProxyFlow/open(withLocalEndpoint:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NEAppProxyFlow(im)openWithLocalEndpoint:completionHandler:"
  },
  "title" : "open(withLocalEndpoint:completionHandler:)"
}
-->

# open(withLocalEndpoint:completionHandler:)

Opens the flow, indicating to the system that the caller is ready to start receiving and sending data.

```
func open(withLocalEndpoint localEndpoint: NWHostEndpoint?, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

`localEndpoint`

An [`NWHostEndpoint`](/documentation/NetworkExtension/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     <doc://com.apple.documentation/documentation/Network/NWPath/localEndpoint>     property of the current path. If it used BSD Sockets, it gets this information by calling     `getsockname`    .

    Pass     `nil`     to 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 `nil` value indicates the flow opened successfully. A non-`nil` value indicates the flow could not be opened. See [`NEAppProxyFlowError`](/documentation/NetworkExtension/NEAppProxyFlowError-swift.struct) for a list of expected error codes.

## Discussion

An [`NEAppProxyFlow`](/documentation/NetworkExtension/NEAppProxyFlow) object starts out in the unopened state. When the system passes a flow to your app proxy provider by calling [`handleNewFlow(_:)`](/documentation/NetworkExtension/NEAppProxyProvider/handleNewFlow(_:)), to need to set up the state necessary to handle the flow’s data, and then call this method.

---

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)