createTCPConnection(to:enableTLS:tlsParameters:delegate:)
Create a TCP connection.
Declaration
func createTCPConnection(to remoteEndpoint: NWEndpoint, enableTLS: Bool, tlsParameters TLSParameters: NWTLSParameters?, delegate: Any?) -> NWTCPConnectionParameters
- 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
enableTLSis True and this parameter is nil then the default TLS parameters will be used. - delegate:
An optional delegate object that conforms to the Nwtcpconnectionauthenticationdelegate protocol.
Return Value
A NWTCPConnection object. The underlying connection is in the process of being established. You can observe the connection’s state property using KVO to determine when the connection is successfully established or fails due to an error. For information about KVO, see Key-Value Observing Programming Guide.
Discussion
This method provides a convenient way to create TCP connections from a Network Extension Provider. It is preferred over using the sockets API. For instance, the Tunnel Provider can use this method to create a secure TCP connection with the tunnel server that can be used to tunnel network data.