Contents

read(_:maxLength:)

Reads up to a given number of bytes into a given buffer.

Declaration

func read(_ buffer: UnsafeMutablePointer<UInt8>, maxLength len: Int) -> Int

Parameters

  • buffer:

    A data buffer. The buffer must be large enough to contain the number of bytes specified by len.

  • len:

    The maximum number of bytes to read.

Return Value

A number indicating the outcome of the operation:

Discussion

  • A positive number indicates the number of bytes read.

  • 0 indicates that the end of the buffer was reached.

  • -1 means that the operation failed; more information about the error can be obtained with streamError.

See Also

Using Streams