Instance Method

createTCPConnectionToEndpoint:enableTLS:TLSParameters:delegate:

Create a TCP connection.

Declaration

- (NWTCPConnection *)createTCPConnectionToEndpoint:(NWEndpoint *)remoteEndpoint enableTLS:(BOOL)enableTLS TLSParameters:(NWTLSParameters *)TLSParameters delegate:(id)delegate;

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 YES 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.

See Also

Creating Network Connections

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software