Function

CFStreamCreatePairWithSocketToHost

Creates readable and writable streams connected to a TCP/IP port of a particular host.

Declaration

void CFStreamCreatePairWithSocketToHost(CFAllocatorRef alloc, CFStringRef host, UInt32 port, CFReadStreamRef  _Null_unspecified *readStream, CFWriteStreamRef  _Null_unspecified *writeStream);

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.

host

The hostname to which the socket streams should connect. The host can be specified using an IPv4 or IPv6 address or a fully qualified DNS hostname.

port

The TCP port number to which the socket streams should connect.

readStream

Upon return, a readable stream connected to the socket address in port. If you pass NULL, this function will not create a readable stream. Ownership follows the The Create Rule.

writeStream

Upon return, a writable stream connected to the socket address in port. If you pass NULL, this function will not create a writable stream. Ownership follows the The Create Rule.

Discussion

The streams do not create a socket, resolve the hostname, or connect to the remote 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.

See Also

Creating Streams

CFStreamCreatePairWithPeerSocketSignature

Creates readable and writable streams connected to a socket.

CFStreamCreatePairWithSocket

Creates readable and writable streams connected to a socket.

CFStreamCreateBoundPair

Creates a bound pair of read and write streams.

CFStreamCreatePairWithSocketToCFHost

Creates readable and writable streams connected to a given CFHost object.

CFStreamCreatePairWithSocketToNetService

Creates a pair of streams for a CFNetService.