Function

CFStreamCreatePairWithSocketToNetService(_:_:_:_:)

Creates a pair of streams for a CFNetService.

Declaration

func CFStreamCreatePairWithSocketToNetService(_ alloc: CFAllocator?, _ service: CFNetService, _ readStream: UnsafeMutablePointer<Unmanaged<CFReadStream>?>?, _ writeStream: UnsafeMutablePointer<Unmanaged<CFWriteStream>?>?)

Parameters

alloc

The allocator to use to allocate memory for the CFReadStream and CFWriteStream objects. Pass NULL or kCFAllocatorDefault to use the current default allocator.

service

Reference to the CFNetService to which the streams are to be connected. If the service is not resolved, the service will be resolved before the streams are connected.

readstream

Upon return, contains a CFReadStream object connected to the service specified by service, or NULL if there is a failure during creation. If you pass NULL, the function will not create a readable stream. Ownership follows the The Create Rule.

writeStream

Upon return, contains a CFWriteStream object connected to the service specified by service, or NULL if there is a failure during creation. If you pass NULL, the function will not create a writable stream. Ownership follows the The Create Rule.

Discussion

The streams do not create a socket, resolve the service, or connect to the service’s host until you open one of the streams.

Most properties are shared by both streams. Setting a shared property for one stream automatically sets the property for the other.

Special Considerations

This function is thread safe.

See Also

Streams

func CFReadStreamCreateForStreamedHTTPRequest(CFAllocator?, CFHTTPMessage, CFReadStream) -> Unmanaged<CFReadStream>

Creates a read stream for a CFHTTP request message object whose body is too long to keep in memory.

Deprecated
let kCFStreamPropertyHTTPFinalRequest: CFString

HTTP Final Request property. A value of type CFHTTPMessage containing the final message transmitted by the stream after all modifications (including authentication, connection policy, redirects, and so on) have been made. This property cannot be set.

Deprecated
let kCFStreamPropertyHTTPFinalURL: CFString

HTTP Final URL property. A value of type CFURL containing the final HTTP URL. This value differs from the URL in the original HTTP request if an autoredirection occurred. This property cannot be set.

Deprecated
let kCFStreamPropertyHTTPResponseHeader: CFString

HTTP Response Header property. When copied by CFReadStreamCopyProperty(_:_:), the header of an HTTP response message is returned.

Deprecated
let kCFStreamPropertyHTTPShouldAutoredirect: CFString

HTTP Should Auto Redirect property. Set this property to kCFBooleanTrue to enable autoredirection; set this property to kCFBooleanFalse to disable autoredirection.

Deprecated
let kCFStreamPropertyFTPFileTransferOffset: CFString

FTP File Transfer Offset stream property key for set and copy operations. The value of this property is a CFNumber of type kCFNumberLongLongType representing the file offset at which to start the transfer.

Deprecated
let kCFStreamPropertyFTPPassword: CFString

FTP Password stream property key for set and copy operations. A value of type CFString for storing the login password. Don’t set this property when anonymous FTP is desired.

Deprecated
let kCFStreamPropertyFTPProxy: CFString

FTP Proxy stream property key for set and copy operations. The property is a value of type CFDictionary that holds proxy dictionary key-value pairs. The dictionary returned by SystemConfiguration can also be set as the value of this property.

Deprecated
let kCFStreamPropertyFTPResourceSize: CFString

FTP Resource Size read stream property key copy operations. This property stores a CFNumber of type kCFNumberLongLongType representing the size of a resource in bytes.

Deprecated
let kCFStreamPropertyFTPUsePassiveMode: CFString

FTP Passive Mode stream property key for set and copy operations. Set this property to kCFBooleanTrue to enable passive mode; set this property to kCFBooleanFalse to disable passive mode.

Deprecated
let kCFStreamPropertyFTPUserName: CFString

FTP User Name stream property key for set and copy operations. A value of type CFString for storing the login user name. Don’t set this property when anonymous FTP is desired.

Deprecated
func CFSocketStreamSOCKSGetError(UnsafePointer<CFStreamError>) -> Int32

This function gets error codes in the kCFStreamErrorDomainSOCKS domain from the CFStreamError returned by a stream operation.

func CFSocketStreamSOCKSGetErrorSubdomain(UnsafePointer<CFStreamError>) -> Int32

Gets the error subdomain associated with errors in the kCFStreamErrorDomainSOCKS domain from the CFStreamError returned by a stream operation.

let kCFStreamNetworkServiceType: CFString

The type of service for the stream. Providing the service type allows the system to properly handle certain attributes of the stream, including routing and suspension behavior. Most streams do not need to set this property. See Stream Service Types for a list of possible values.

let kCFStreamNetworkServiceTypeBackground: CFString

Specifies that the stream is a background download.

let kCFStreamNetworkServiceTypeVideo: CFString

Specifies that the stream is providing interactive video data.

let kCFStreamNetworkServiceTypeVoIP: CFString

Specifies that the stream is providing VoIP service.

Deprecated
let kCFStreamNetworkServiceTypeVoice: CFString

Specifies that the stream is providing interactive voice data.

let kCFStreamErrorDomainFTP: Int32

The error code is an FTP error code.

let kCFStreamErrorDomainHTTP: Int32

The error code is an HTTP error code.

let kCFStreamErrorDomainMach: Int32

The error code is a Mach error code defined in mach/error.h.

let kCFStreamErrorDomainNetDB: Int32

The error code is an error code defined in netdb.h.

let kCFStreamErrorDomainNetServices: Int32

The error code is a CFNetService error code. For details, see the CFNetServicesError enumeration.

let kCFStreamErrorDomainSOCKS: Int32

The error code is a SOCKS proxy error.

let kCFStreamErrorDomainSSL: Int32

The error code is an SSL error code as defined in Security/SecureTransport.h.

let kCFStreamErrorDomainSystemConfiguration: Int32

The error code is a system configuration error code as defined in System/ConfigurationSystemConfiguration.h.

let kCFStreamErrorDomainWinSock: CFIndex

When running CFNetwork code on Windows, this domain returns error codes associated with the underlying TCP/IP stack. You should also note that non-networking errors such as ENOMEM are delivered through the POSIX domain. See the header winsock2.h for relevant error codes.

let kCFStreamPropertyConnectionIsCellular: CFString

A boolean value indicating whether the stream is connected over a cellular (WWAN) interface. This is a read-only property, and is false until the connection has been established.

let kCFStreamPropertyNoCellular: CFString

A Boolean value indicating that the connection should not be established over a cellular (WWAN) connection. This value can only be set before you open the stream.

let kCFStreamPropertyProxyLocalBypass: CFString

Proxy Local Bypass property key.

let kCFStreamPropertySOCKSPassword: CFString

Constant for the key required to set a user’s password.

let kCFStreamPropertySOCKSProxyHost: CFString

Constant for the SOCKS proxy host key.

let kCFStreamPropertySOCKSProxyPort: CFString

Constant for the SOCKS proxy host port key.

let kCFStreamPropertySOCKSUser: CFString

Constant for the key required to set a user name.

let kCFStreamPropertySOCKSVersion: CFString

Constant for the SOCKS version key.

let kCFStreamPropertySSLPeerTrust: CFString

SSL Peer Trust property key for copy operations, which return a SecTrustRef object containing the result of the SSL handshake.

let kCFStreamPropertySSLSettings: CFString

SSL Settings property key for set operations.

let kCFStreamPropertyShouldCloseNativeSocket: CFString

Should Close Native Socket property key.

let kCFStreamPropertySocketRemoteHost: CFString

The key’s value is a CFHostRef for the remote host if it is known. If not, its value is NULL.

let kCFStreamPropertySocketRemoteNetService: CFString

The key’s value is a CFNetServiceRef for the remote network service if it is known. If not, its value is NULL.

let kCFStreamPropertySocketSecurityLevel: CFString

Socket Security Level property key.

let kCFStreamSSLCertificates: CFString

Security property key whose value is a CFArray of SecCertificateRefs except for the first element in the array, which is a SecIdentityRef.

let kCFStreamSSLIsServer: CFString

Security property key whose value indicates whether the connection is to act as a server in the SSL process.

let kCFStreamSSLLevel: CFString

Security property key whose value specifies the stream’s security level.

let kCFStreamSSLPeerName: CFString

Security property key whose value overrides the name used for certificate verification.

let kCFStreamSSLValidatesCertificateChain: CFString

Security property key whose value indicates whether the certificate chain should be validated.

let kCFStreamSocketSOCKSVersion4: CFString

Constant used in the kCFStreamSockerSOCKSVersion key to specify SOCKS4 as the SOCKS version for the stream.

let kCFStreamSocketSOCKSVersion5: CFString

Constant used in the kCFStreamSOCKSVersion key to specify SOCKS5 as the SOCKS version for the stream.

let kCFStreamSocketSecurityLevelNegotiatedSSL: CFString

Specifies that the highest level security protocol that can be negotiated be set as the security protocol for a socket stream.

let kCFStreamSocketSecurityLevelNone: CFString

Specifies that no security level be set.

let kCFStreamSocketSecurityLevelSSLv2: CFString

Specifies that SSL version 2 be set as the security protocol for a socket stream.

Deprecated
let kCFStreamSocketSecurityLevelSSLv3: CFString

Specifies that SSL version 3 be set as the security protocol for a socket stream pair.

Deprecated
let kCFStreamSocketSecurityLevelTLSv1: CFString

Specifies that TLS version 1 be set as the security protocol for a socket stream.

enum CFStreamErrorHTTP

Error codes that a read stream for an HTTP request may return.

enum CFStreamErrorHTTPAuthentication

Authentication error codes that may be returned when trying to apply authentication to a request.

Secure Sockets (SOCKS) Errors

Error codes returned by the kCFStreamErrorDomainSOCKS error domain.