<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFWriteStreamOpen(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFWriteStreamOpen"
  },
  "title" : "CFWriteStreamOpen(_:)"
}
-->

# CFWriteStreamOpen(_:)

Opens a stream for writing.

```
func CFWriteStreamOpen(_ stream: CFWriteStream!) -> Bool
```

## Parameters

`stream`

The stream to open.

## Return Value

`true` if `stream` was successfully opened, `false` otherwise. If `stream` is not in the [`CFStreamStatus.notOpen`](/documentation/CoreFoundation/CFStreamStatus/notOpen) 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 [`CFWriteStreamScheduleWithRunLoop(_:_:_:)`](/documentation/CoreFoundation/CFWriteStreamScheduleWithRunLoop(_:_:_:)) and wait for the stream’s client (set with [`CFWriteStreamSetClient(_:_:_:_:)`](/documentation/CoreFoundation/CFWriteStreamSetClient(_:_:_:_:))) to be notified or you can poll the stream using [`CFWriteStreamGetStatus(_:)`](/documentation/CoreFoundation/CFWriteStreamGetStatus(_:)), waiting for a status of [`CFStreamStatus.open`](/documentation/CoreFoundation/CFStreamStatus/open) or [`CFStreamStatus.error`](/documentation/CoreFoundation/CFStreamStatus/error).

---

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)