<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFReadStream",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@T@CFReadStreamRef"
  },
  "title" : "CFReadStream"
}
-->

# CFReadStream

```
class CFReadStream
```

## Overview

`CFReadStream` provides an interface for reading a byte stream either synchronously or asynchronously. You can create streams that read bytes from a block of memory, a file, or a generic socket. All streams need to be opened, using [`CFReadStreamOpen(_:)`](/documentation/CoreFoundation/CFReadStreamOpen(_:)), before reading.

Use [`CFWriteStream`](/documentation/CoreFoundation/CFWriteStream) for writing byte streams. The CFNetwork framework defines an additional type of stream for reading responses to HTTP requests.

CFReadStream is “toll-free bridged” with its Cocoa Foundation counterpart, <doc://com.apple.documentation/documentation/Foundation/InputStream>. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an `NSInputStream *` parameter, you can pass in a CFReadStreamRef, and in a function where you see a CFReadStreamRef parameter, you can pass in an `NSInputStream` instance. Note, however, that you may have either a delegate or callbacks but not both. See [Toll-Free Bridged Types](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFDesignConcepts/Articles/tollFreeBridgedTypes.html#//apple_ref/doc/uid/TP40010677) for more information on toll-free bridging.

## Topics

### Creating a Read Stream

[`CFReadStreamCreateWithBytesNoCopy(_:_:_:_:)`](/documentation/CoreFoundation/CFReadStreamCreateWithBytesNoCopy(_:_:_:_:))

Creates a readable stream for a block of memory.

[`CFReadStreamCreateWithFile(_:_:)`](/documentation/CoreFoundation/CFReadStreamCreateWithFile(_:_:))

Creates a readable stream for a file.

### Opening and Closing a Read Stream

[`CFReadStreamClose(_:)`](/documentation/CoreFoundation/CFReadStreamClose(_:))

Closes a readable stream.

[`CFReadStreamOpen(_:)`](/documentation/CoreFoundation/CFReadStreamOpen(_:))

Opens a stream for reading.

### Reading from a Stream

[`CFReadStreamRead(_:_:_:)`](/documentation/CoreFoundation/CFReadStreamRead(_:_:_:))

Reads data from a readable stream.

### Scheduling a Read Stream

[`CFReadStreamScheduleWithRunLoop(_:_:_:)`](/documentation/CoreFoundation/CFReadStreamScheduleWithRunLoop(_:_:_:))

Schedules a stream into a run loop.

[`CFReadStreamUnscheduleFromRunLoop(_:_:_:)`](/documentation/CoreFoundation/CFReadStreamUnscheduleFromRunLoop(_:_:_:))

Removes a read stream from a given run loop.

### Examining Stream Properties

[`CFReadStreamCopyProperty(_:_:)`](/documentation/CoreFoundation/CFReadStreamCopyProperty(_:_:))

Returns the value of a property for a stream.

[`CFReadStreamGetBuffer(_:_:_:)`](/documentation/CoreFoundation/CFReadStreamGetBuffer(_:_:_:))

Returns a pointer to a stream’s internal buffer of unread data, if possible.

[`CFReadStreamCopyError(_:)`](/documentation/CoreFoundation/CFReadStreamCopyError(_:))

Returns the error associated with a stream.

[`CFReadStreamGetError(_:)`](/documentation/CoreFoundation/CFReadStreamGetError(_:))

Returns the error status of a stream.

[`CFReadStreamGetStatus(_:)`](/documentation/CoreFoundation/CFReadStreamGetStatus(_:))

Returns the current state of a stream.

[`CFReadStreamHasBytesAvailable(_:)`](/documentation/CoreFoundation/CFReadStreamHasBytesAvailable(_:))

Returns a Boolean value that indicates whether a readable stream has data that can be read without blocking.

### Setting Stream Properties

[`CFReadStreamSetClient(_:_:_:_:)`](/documentation/CoreFoundation/CFReadStreamSetClient(_:_:_:_:))

Assigns a client to a stream, which receives callbacks when certain events occur.

[`CFReadStreamSetProperty(_:_:_:)`](/documentation/CoreFoundation/CFReadStreamSetProperty(_:_:_:))

Sets the value of a property for a stream.

### Getting the CFReadStream Type ID

[`CFReadStreamGetTypeID()`](/documentation/CoreFoundation/CFReadStreamGetTypeID())

Returns the type identifier the `CFReadStream` opaque type.

### Callbacks

[`CFReadStreamClientCallBack`](/documentation/CoreFoundation/CFReadStreamClientCallBack)

Callback invoked when certain types of activity takes place on a readable stream.

### Data Types

[`CFStreamClientContext`](/documentation/CoreFoundation/CFStreamClientContext)

A structure that contains program-defined data and callbacks with which you can configure a stream’s client behavior.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)