CFWriteStream

Overview

CFWriteStream provides an interface for writing a byte stream either synchronously or asynchronously. You can create streams that write bytes to a block of memory, a file, or a generic socket. All streams need to be opened, using CFWriteStreamOpen, before writing.

Use CFReadStream for reading byte streams, and for the functions, such as CFStreamCreatePairWithSocketToHost, that create socket streams).

CFWriteStream is “toll-free bridged” with its Cocoa Foundation counterpart, NSOutputStream. 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 NSOutputStream * parameter, you can pass in a CFWriteStreamRef, and in a function where you see a CFWriteStreamRef parameter, you can pass in an NSOutputStream instance. Note, however, that you may have either a delegate or callbacks but not both. See Toll-Free Bridged Types for more information on toll-free bridging.

Topics

Creating a Write Stream

CFWriteStreamCreateWithAllocatedBuffers

Creates a writable stream for a growable block of memory.

CFWriteStreamCreateWithBuffer

Creates a writable stream for a fixed-size block of memory.

CFWriteStreamCreateWithFile

Creates a writable stream for a file.

Opening and Closing a Stream

CFWriteStreamClose

Closes a writable stream.

CFWriteStreamOpen

Opens a stream for writing.

Writing to a Stream

CFWriteStreamWrite

Writes data to a writable stream.

Scheduling a Write Stream

CFWriteStreamScheduleWithRunLoop

Schedules a stream into a run loop.

CFWriteStreamUnscheduleFromRunLoop

Removes a stream from a particular run loop.

Examining Stream Properties

CFWriteStreamCanAcceptBytes

Returns whether a writable stream can accept new data without blocking.

CFWriteStreamCopyProperty

Returns the value of a property for a stream.

CFWriteStreamCopyError

Returns the error associated with a stream.

CFWriteStreamGetError

Returns the error status of a stream.

CFWriteStreamGetStatus

Returns the current state of a stream.

Setting Stream Properties

CFWriteStreamSetClient

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

CFWriteStreamSetProperty

Sets the value of a property for a stream.

Getting the CFWriteStream Type ID

CFWriteStreamGetTypeID

Returns the type identifier of all CFWriteStream objects.

Callbacks

CFWriteStreamClientCallBack

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

Data Types

CFWriteStreamRef

A reference to a writable stream object.

See Also

Opaque Types

CFFileDescriptor

The CFFileDescriptor provides an opaque type to monitor file descriptors for read and write activity via CFRunLoop.

CFStringTokenizer

CFStringTokenizer allows you to tokenize strings into words, sentences or paragraphs in a language-neutral way. It supports languages such as Japanese and Chinese that do not delimit words by spaces, as well as de-compounding German compounds. You can obtain Latin transcription for tokens. It also provides language identification API.