Class

NWTCPConnection

An object to manage a TCP connection, with or without TLS.

Declaration

class NWTCPConnection : NSObject

Topics

Monitoring the Connection Status

var state: NWTCPConnectionState

The status of the connection

enum NWTCPConnectionState

Defined connection states. New types may be defined in the future.

var isViable: Bool

The viability of a TCP connection indicates whether or not data can be transferred

var error: Error?

The connection-wide error property

Transferring Data

Canceling the Connection

func cancel()

Cancel the connection

Responding to Network Changes

var hasBetterPath: Bool

If a connection has a better path, new connections would use a different interface

init(upgradeFor: NWTCPConnection)

This convenience initializer can be used to create a new connection that wil only be connected if there exists a better path (as determined by the system) to the remote endpoint of the original connection.

Getting Connection Properties

var endpoint: NWEndpoint

The destination endpoint with which this connection was created

var localAddress: NWEndpoint?

The IP address endpoint from which the connection was established

var remoteAddress: NWEndpoint?

The IP address endpoint to which the connection was established

var connectedPath: NWPath?

The network path over which the connection was established

var txtRecord: Data?

The TXT record associated with a connected Bonjour service endpoint

Relationships

Inherits From

Conforms To

See Also

TCP Connections

class NWTLSParameters

TLS properties for creating a connection.

protocol NWTCPConnectionAuthenticationDelegate

A delegate protocol to customize the TLS authentication done by a connection.