| Derived from | |
| Framework | |
| Companion guide | |
| Declared in | CFSocketStream.h CFStream.h |
This document describes the CFStream functions for working with sockets. It is part of the CFSocketStream API.
This function sets the security protocol for the specified pair of socket streams. (Deprecated. Use CFReadStreamSetProperty and CFWriteStreamSetProperty in conjunction with the security constants defined in CFSocketStream.)
Boolean CFSocketStreamPairSetSecurityProtocol ( CFReadStreamRef socketReadStream, CFWriteStreamRef socketWriteStream, CFStreamSocketSecurityProtocol securityProtocol );
The read stream.
The write stream.
The security protocol to be set. See CFStream Socket Security Protocol Constants for possible values.
TRUE if specified security protocol was set; otherwise, FALSE.
Call this function before you call CFReadStreamOpen to open the read stream or CFWriteStreamOpen to open the write stream.
This function is thread safe.
CFSocketStream.hCreates readable and writable streams connected to a given CFHost object.
void CFStreamCreatePairWithSocketToCFHost ( CFAllocatorRef alloc, CFHostRef host, SInt32 port, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream );
The allocator to use to allocate memory for the CFReadStream and CFWriteStream objects. Pass NULL or kCFAllocatorDefault to use the current default allocator.
A CFHost object to which the streams are connected. If unresolved, the host will be resolved prior to connecting.
The TCP port number to which the socket streams should connect.
Upon return, contains a CFReadStream object connected to the host host on port port, or NULL if there is a failure during creation. If you pass NULL, the function will not create a readable stream. Ownership follows the Create Rule.
Upon return, contains a CFWriteStream object connected to the host host on port port, or NULL if there is a failure during creation. If you pass NULL, the function will not create a writable stream. Ownership follows the Create Rule.
The streams do not open a connection to the specified host until one of the streams is opened.
Most properties are shared by both streams. Setting the property for one stream automatically sets the property for the other.
CFSocketStream.hCreates a pair of streams for a CFNetService.
void CFStreamCreatePairWithSocketToNetService ( CFAllocatorRef alloc, CFNetServiceRef service, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream );
The allocator to use to allocate memory for the CFReadStream and CFWriteStream objects. Pass NULL or kCFAllocatorDefault to use the current default allocator.
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.
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 Create Rule.
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 Create Rule.
Read and write operations on sockets can block. To prevent blocking, you can call CFReadStreamSetClient and CFWriteStreamSetClient to register to receive stream-related event notifications. Then call CFReadStreamScheduleWithRunLoop and CFWriteStreamScheduleWithRunLoop to schedule the stream on a run loop for receiving stream-related event notifications. Then call CFReadStreamOpen and CFWriteStreamOpen to open each stream.
This function is thread safe.
CFSocketStream.hConstants for CFStream property keys
const CFStringRef kCFStreamPropertyShouldCloseNativeSocket; const CFStringRef kCFStreamPropertySocketSecurityLevel; const CFStringRef kCFStreamPropertySOCKSProxy; const CFStringRef kCFStreamPropertySSLPeerCertificates; const CFStringRef kCFStreamPropertySSLSettings; const CFStringRef kCFStreamPropertyProxyLocalByPass;
kCFStreamPropertyShouldCloseNativeSocketShould Close Native Socket property key.
If set to kCFBooleanTrue, the stream will close and release the underlying native socket when the stream is released. If set to kCFBooleanFalse, the stream will not close and release the underlying native socket when the stream is released. If a stream is created with a native socket, the default value of this property is kCFBooleanFalse. This property is only available for socket streams. It can be set by calling CFReadStreamSetProperty and CFWriteStreamSetProperty, and it can be copied by CFReadStreamCopyProperty and CFWriteStreamCopyProperty.
Available in Mac OS X v10.2 and later.
Declared in CFSocketStream.h
kCFStreamPropertySocketNativeHandleSocket Native Handle property key.
Causes CFReadStreamCopyProperty or CFWriteStreamCopyProperty to return CFData object that contains the native handle for a socket stream. This property is only available for socket streams.
Available in Mac OS X v10.1 and later.
Declared in CFStream.h
kCFStreamPropertySocketSecurityLevelSocket Security Level property key.
See CFStream Socket Security Level Constants for specific security level constants to use.
Available in Mac OS X v10.2 and later.
Declared in CFSocketStream.h
kCFStreamPropertySSLPeerCertificatesSSL Peer Certificates property key for copy operations, which return a CFArray object containing SecCertificateRefs.
For more information, see Security/SecureTransport.h.
Available in Mac OS X v10.4 and later.
Declared in CFSocketStream.h
kCFStreamPropertySOCKSProxySOCKS proxy property key.
To set a CFStream object to use a SOCKS proxy, call CFReadStreamSetProperty or CFWriteStreamSetProperty with the property name set to kCFStreamPropertySOCKSProxy and its value set to a CFDictionary object having at minimum a kCFStreamPropertySOCKSProxyHost key and a kCFStreamPropertySOCKSProxyPort key. For information on these keys, see CFStream SOCKS Proxy Key Constants. SystemConfiguration returns a CFDictionary for SOCKS proxies that is usable without modification.
Available in Mac OS X v10.2 and later.
Declared in CFSocketStream.h
kCFStreamPropertySSLSettingsSSL Settings property key for set operations.
The key’s value is a CFDictionary object containing security settings. For information on the dictionary’s keys and values, see CFStream Property SSL Settings Constants. By default, there are no security settings.
Available in Mac OS X v10.4 and later.
Declared in CFSocketStream.h
kCFStreamPropertyProxyLocalBypassProxy Local Bypass property key.
The key’s value is CFBoolean object whose value indicates whether local hostnames should be subject to proxy handling.
Available in Mac OS X v10.4 and later.
Declared in CFSocketStream.h
CFNetwork/CFSocketStream.hConstants for use in a CFDictionary object that is the value of the kCFStreamPropertySSLSettings stream property key.
const CFStringRef kCFStreamSSLLevel; const CFStringRef kCFStreamSSLAllowsExpiredCertificates; const CFStringRef kCFStreamSSLAllowsExpiredRoots; const CFStringRef kCFStreamSSLAllowsAnyRoot; const CFStringRef kCFStreamSSLValidatesCertificateChain; const CFStringRef kCFStreamSSLPeerName; const CFStringRef kCFStreamSSLCertificates; const CFStringRef kCFStreamSSLIsServer;
kCFStreamSSLLevelSecurity property key whose value specifies the stream’s security level.
By default, a stream’s security level is kCFStreamSocketSecurityLevelNegotiatedSSL. For other possible values, see CFStream Socket Security Level Constants.
kCFStreamSSLAllowsExpiredCertificatesSecurity property key whose value indicates whether expired certificates are allowed.
By default, the value of this key is kCFBooleanFalse (expired certificates are not allowed).
kCFStreamSSLAllowsExpiredRootsSecurity property whose value indicates whether expired root certificates are allowed.
By default, the value of this key is kCFBooleanFalse (expired root certificates are not allowed).
kCFStreamSSLAllowsAnyRootSecurity property key whose value indicates whether root certificates should be allowed.
By default, the value of this key is kCFBooleanFalse (root certificates are not allowed).
kCFStreamSSLValidatesCertificateChainSecurity property key whose value indicates whether the certificate chain should be validated.
By default, the value of this key is kCFBooleanTrue (the certificate chain should be validated).
kCFStreamSSLPeerNameSecurity property key whose value overrides the name used for certificate verification.
By default, the host name that was used when the stream was created is used; if no host name was used, no peer name will be used. Set the value of this key to kCFNull to prevent name verification.
kCFStreamSSLCertificatesSecurity property key whose value is a CFArray of SecCertificateRefs except for the first element in the array, which is a SecIdentityRef.
For more information, see SSLSetCertificate() in Security/SecureTransport.h.
kCFStreamSSLIsServerSecurity property key whose value indicates whether the connection is to act as a server in the SSL process.
By default, the value of this key is kCFBooleanFalse (the connection is not to act as a server). If the value of this key is kCFBooleanTrue, the kCFStreamSSLCertificates key must contain a valid value.
This enumeration defines the constants for keys in a CFDictionary object that is the value of the kCFStreamPropertySSLSettings key.
CFNetwork/CFSocketStream.hSpecifies constants for setting the security protocol for a socket stream.
typedef enum {
kCFStreamSocketSecurityNone = 0,
kCFStreamSocketSecuritySSLv2,
kCFStreamSocketSecuritySSLv3,
kCFStreamSocketSecuritySSLv23,
kCFStreamSocketSecurityTLSv1
} CFStreamSocketSecurityProtocol;
kCFStreamSocketSecurityNoneSpecifies that no security protocol be set for a socket stream. (Deprecated. Use kCFStreamSocketSecurityLevelNone.)
Available in Mac OS X v10.1 and later.
Deprecated in Mac OS X v10.2.
Declared in CFSocketStream.h
kCFStreamSocketSecuritySSLv2Specifies that SSL version 2 be set as the security protocol for a socket stream. (Deprecated. Use kCFStreamSocketSecurityLevelSSLv2.)
Available in Mac OS X v10.1 and later.
Deprecated in Mac OS X v10.2.
Declared in CFSocketStream.h
kCFStreamSocketSecuritySSLv3Specifies that SSL version 3 be set as the security protocol for a socket stream. (Deprecated. Use kCFStreamSocketSecurityLevelSSLv3.)
Available in Mac OS X v10.1 and later.
Deprecated in Mac OS X v10.2.
Declared in CFSocketStream.h
kCFStreamSocketSecuritySSLv23Specifies that SSL version 3 be set as the security protocol for a socket stream pair. If that version is not available, specifies that SSL version 2 be set as the security protocol for a socket stream. (Deprecated. Use kCFStreamSocketSecurityLevelNegotiatedSSL.)
Available in Mac OS X v10.1 and later.
Deprecated in Mac OS X v10.2.
Declared in CFSocketStream.h
kCFStreamSocketSecurityTLSv1Specifies that TLS version 1 be set as the security protocol for a socket stream. (Deprecated. Use kCFStreamSocketSecurityLevelTLSv1.)
Available in Mac OS X v10.1 and later.
Deprecated in Mac OS X v10.2.
Declared in CFSocketStream.h
This enumeration defines constants for setting the security protocol for a socket stream pair when calling CFSocketStreamPairSetSecurityProtocol.
This enumeration is deprecated in favor of the constants described in CFStream Socket Security Level Constants.
CFNetwork/CFSocketStream.hConstants for setting the security level of a socket stream.
const CFStringRef kCFStreamSocketSecurityLevelNone; const CFStringRef kCFStreamSocketSecurityLevelSSLv2; const CFStringRef kCFStreamSocketSecurityLevelSSLv3; const CFStringRef kCFStreamSocketSecurityLevelTLSv1; const CFStringRef kCFStreamSocketSecurityLevelNegotiatedSSL;
kCFStreamSocketSecurityLevelNoneSpecifies that no security level be set.
kCFStreamSocketSecurityLevelSSLv2Specifies that SSL version 2 be set as the security protocol for a socket stream.
kCFStreamSocketSecurityLevelSSLv3Specifies that SSL version 3 be set as the security protocol for a socket stream pair.
If SSL version 3 is not available, specifies that SSL version 2 be set as the security protocol for a socket stream.
kCFStreamSocketSecurityLevelTLSv1Specifies that TLS version 1 be set as the security protocol for a socket stream.
kCFStreamSocketSecurityLevelNegotiatedSSLSpecifies that the highest level security protocol that can be negotiated be set as the security protocol for a socket stream.
This enumeration defines the preferred constants for setting the security protocol for a socket stream pair when calling CFReadStreamSetProperty or CFWriteStreamSetProperty.
CFNetwork/CFSocketStream.hConstants for SOCKS Proxy CFDictionary keys.
const CFStringRef kCFStreamPropertySOCKSProxyHost; const CFStringRef kCFStreamPropertySOCKSProxyPort; const CFStringRef kCFStreamPropertySOCKSVersion; const CFStringRef kCFStreamSocketSOCKSVersion4; const CFStringRef kCFStreamSocketSOCKSVersion5; const CFStringRef kCFStreamPropertySOCKSUser; const CFStringRef kCFStreamPropertySOCKSPassword;
kCFStreamPropertySOCKSProxyHostConstant for the SOCKS proxy host key.
This key contains a CFString object that represents the SOCKS proxy host. Defined to match kSCPropNetProxiesSOCKSProxy.
kCFStreamPropertySOCKSProxyPortConstant for the SOCKS proxy host port key.
This key contains a CFNumberRef object of type kCFNumberSInt32Type whose value represents the port on which the proxy listens.
kCFStreamPropertySOCKSVersionConstant for the SOCKS version key.
Its value must be kCFStreamSocketSOCKSVersion4 or kCFStreamSocketSOCKSVersion5 to set SOCKS4 or SOCKS5, respectively. If this key is not present, SOCKS5 is used by default.
kCFStreamSocketSOCKSVersion4Constant used in the kCFStreamSockerSOCKSVersion key to specify SOCKS4 as the SOCKS version for the stream.
kCFStreamSocketSOCKSVersion5Constant used in the kCFStreamSOCKSVersion key to specify SOCKS5 as the SOCKS version for the stream.
kCFStreamPropertySOCKSUserConstant for the key required to set a user name.
The value is a CFString object containing the user’s name.
kCFStreamPropertySOCKSPasswordConstant for the key required to set a user’s password.
The value is a CFString object containing the user’s password.
When setting the stream's SOCKS Proxy property, the property’s value is a CFDictionary object containing at minimum the kCFStreamPropertySOCKSProxyHost and kCFStreamPropertySOCKSProxyPort keys. The dictionary may also contain the other keys described in this section.
Last updated: 2006-07-06