Function

CFReadStreamOpen

Opens a stream for reading.

Declaration

Boolean CFReadStreamOpen(CFReadStreamRef stream);

Parameters

stream

The stream to open.

Return Value

TRUE if stream was successfully opened, FALSE otherwise. If stream is not in the kCFStreamStatusNotOpen state, this function returns FALSE.

Discussion

Opening a stream causes it to reserve all the system resources it requires. If the stream can open in the background without blocking, this function always returns true. To learn when a background open operation completes, you can either schedule the stream into a run loop with CFReadStreamScheduleWithRunLoop and wait for the stream’s client (set with CFReadStreamSetClient) to be notified or you can poll the stream using CFReadStreamGetStatus, waiting for a status of kCFStreamStatusOpen or kCFStreamStatusError.

You do not need to wait until a stream has finished opening in the background before calling the CFReadStreamRead function. The read operation will simply block until the open has completed.

See Also

Opening and Closing a Read Stream

CFReadStreamClose

Closes a readable stream.

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