---
title: "createTCPConnectionThroughTunnel(to:enableTLS:tlsParameters:delegate:)"
framework: networkextension
role: symbol
role_heading: Instance Method
path: "networkextension/nepackettunnelprovider/createtcpconnectionthroughtunnel(to:enabletls:tlsparameters:delegate:)"
---

# createTCPConnectionThroughTunnel(to:enableTLS:tlsParameters:delegate:)

Create a TCP connection through the current tunnel.

## Declaration

```swift
func createTCPConnectionThroughTunnel(to remoteEndpoint: NWEndpoint, enableTLS: Bool, tlsParameters TLSParameters: NWTLSParameters?, delegate: Any?) -> NWTCPConnection
```

## Parameters

- `remoteEndpoint`: The remote endpoint to connect to.
- `enableTLS`: A flag indicating if the TLS protocol should be used to secure the communication over the connection.
- `TLSParameters`: The TLS protocol parameters to use. If enableTLS is doc://com.apple.documentation/documentation/Swift/true and this parameter is nil then the default TLS parameters will be used.
- `delegate`: An optional delegate object that conforms to the doc://com.apple.networkextension/documentation/NetworkExtension/NWTCPConnectionAuthenticationDelegate protocol.

## Discussion

Discussion Use this method to create a TCP connection to an endpoint inside the private network.

## See Also

### Creating network connections through the tunnel

- [createUDPSessionThroughTunnel(to:from:)](networkextension/nepackettunnelprovider/createudpsessionthroughtunnel(to:from:).md)
