Reads data from a readable stream.
SDKs
- iOS 2.0+
- macOS 10.1+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Core Foundation
Declaration
func CFReadStreamRead(_ stream: CFRead Stream!, _ buffer: Unsafe Mutable Pointer<UInt8>!, _ bufferLength: CFIndex) -> CFIndex
Parameters
stream
The stream from which to read.
buffer
The buffer into which to place the data.
bufferLength
The size of
buffer
and the maximum number of bytes to read.
Return Value
The number of bytes read; 0
if the stream has reached its end; or -1
if either the stream is not open or an error occurs.
Discussion
If stream
is in the process of opening, this function waits until it has completed. This function blocks until at least one byte is available; it does not block until buffer
is filled. To avoid blocking, call this function only if CFRead
returns TRUE
or after the stream’s client (set with CFRead
) is notified of a has
event.