Internet Direct (Indy) Version 9.0.1 Beta
TIdTCPConnection.ReadStream
Reads data from the Indy buffer and stores the values in a stream.

procedure ReadStream(AStream: TStream; AByteCount: LongInt; const AReadUntilDisconnect: boolean);
Parameters
AStream: TStream
Stream where data will be stored.

AByteCount: LongInt = -1
Number of bytes to be read. Default value is -1.

const AReadUntilDisconnect: boolean = false
Indicates that data should be read from the protocol stack until disconnected. Default value is False.

Description
ReadStream is a procedure used to read and extract data from the Indy buffer, and to place the resulting values in the stream specified in AStream.

AByteCount indicates the number of bytes to be read from the Indy buffer, or -1 if all bytes in the Indy buffer should be included. When AByteCount contains the number of bytes to be read, it is used to increase the size of AStream by the given number of bytes. This reduces memory or disk allocations to a single operation.

AReadUntilDisconnected indicates that data should be read from the protocol stack until the component is disconnected. When AReadUntilDisconnected is True, bytes are read from the protocol stack and written to AStream until Connected is False.

Note: When AByteCount is -1, and AReadUntilDisconnected is False, it is assumed that the first 4-bytes in the Indy buffer contains the length of buffered data in Internet format. ReadStream uses ReadInteger to convert the value to Intel byte-order prior to reading the remaining data from the Indy buffer.