Indy 9 | Content | Index | Reference

TIdTCPStream
Hierarchy, Properties, Methods, See Also, Unit: IdTCPStream
Implements support for redirecting stream input and output to a socket connection.

    TIdTCPStream = class(TStream)

Unit
IdTCPStream
Description
TIdTCPStream is a TStream descendant that implements support for redirecting input and output on a TStream descendant to a TIdTCPConnection socket handle. TIdTCPStream reimplements the common TStream methods, Read, Write, and Seek, to provide the functionality needed for redirecting input and output.

TIdTCPStream.Connection
TIdTCPStream, See Also
Represents the connection used for performing input and output for the stream descendant.

    property Connection: TIdTCPConnection;

Description
Connection is a read-only TIdTCPConnection property that represents the socket connection used for performing input and output for the stream descendant.

Connection is assigned in the Create constructor, and is used to perform the actual input or output operation requested by method in the TStream descendant, like Read, Write, and Seek.

TIdTCPStream.Create
TIdTCPStream, See Also
Constructor for the object instance.

    constructor Create(AConnection: TIdTCPConnection); reintroduce;

Parameters
AConnection: TIdTCPConnection
Connection used for stream input and output operations.
Description
Create is the Constructor for the object instance that is reintroduced in TIdTCPStream, and relies the inherited Create method. Create also assigns the TIdTCPConnection instance in the AConnection parameter to the Connection property.

TIdTCPStream.Read
TIdTCPStream, See Also
Implements stream input from a socket connection.

    function Read(var ABuffer; ACount: Longint): Longint; override;

Parameters
var ABuffer
Buffer to receive values read from the socket connection.
ACount: Longint
Number of Bytes read from the socket connection.
Return Value
LongInt - Number of bytes read from the socket connection.
Description
Read is an overriden LongInt function that implements stream input from the associated socket handle in Connection. Read calls TIdTCPConnection.ReadBuffer using the input parameters ABuffer and ACount to perform input of values from the Connection. Values read from the socket Connection are stored in the ABuffer input parameter. The return value for Read is the actual number of bytes read from the Connection and stored in the input variable ACount.

TIdTCPStream.Seek
TIdTCPStream, See Also
Reimplements locating a position in a stream.

    function Seek(AOffset: Longint; AOrigin: Word): Longint; override;

Parameters
AOffset: Longint
Number of bytes to move in the stream from the specified position.
AOrigin: Word
Identifies the origin for the AOffset parameter.
Return Value
Longint - New Position in the stream.
Description
Seek is an overridden LongInt function that reimplements locating a position in the TStream descendant.

Note: Because input and output operations are redirected to a socket connect, and values are not written to the stream, TIdTCPStream does not support seeking a location in the TStream descendant. The return value for Seek, the new Position in the stream, is always -1.

TIdTCPStream.Write
TIdTCPStream, See Also
Reimplements support for writing stream contents to a socket connection.

    function Write(const ABuffer; ACount: Longint): Longint; override;

Parameters
const ABuffer
Values to be written to the socket connection.
ACount: Longint
Number of bytes written to the socket connection.
Return Value
LongInt - Number of bytes written to the socket connection.
Description
Write is an overridden LongInt function that reimplements support for writing TStream contents to the socket handle specified in Connection. Write calls the TIdTCPConnection.WriteBuffer method, using the input parameters ABuffer and ACount, to perform the physical output of values to the socket connection. The return value for Write is the updated value of the ACount input parameter after the call to TIdTCPConnection.WriteBuffer.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.