---
title: "createUDPSessionThroughTunnel(to:from:)"
framework: networkextension
role: symbol
role_heading: Instance Method
path: "networkextension/nepackettunnelprovider/createudpsessionthroughtunnel(to:from:)"
---

# createUDPSessionThroughTunnel(to:from:)

Creates a UDP session through the current tunnel.

## Declaration

```swift
func createUDPSessionThroughTunnel(to remoteEndpoint: NWEndpoint, from localEndpoint: NWHostEndpoint?) -> NWUDPSession
```

## Parameters

- `remoteEndpoint`: The remote endpoint to send UDP datagrams to.
- `localEndpoint`: The local endpoint to bind the UDP session to. If nil, the UDP session will be bound to an ephemeral port on the virtual interface.

## Discussion

Discussion Use this method to create a UDP session to an endpoint inside the private network.

## See Also

### Creating network connections through the tunnel

- [createTCPConnectionThroughTunnel(to:enableTLS:tlsParameters:delegate:)](networkextension/nepackettunnelprovider/createtcpconnectionthroughtunnel(to:enabletls:tlsparameters:delegate:).md)
