Indy 9 | Content | Index | Reference

TIdIOHandler
Hierarchy, Properties, Methods, Events, See Also, Unit: IdIOHandler
Defines the framework for input and output using Indy components.

    TIdIOHandler = class(TIdComponent)

Unit
IdIOHandler
Description
TIdIOHandler is a TIdComponent descendant that defines the framework used to perform input and output operations for Indy components. TIdIOHandler is an abstract ancestor classes. Applications should create an instance of a descendant class, like TIdIOHandlerSocket or TIdIOHandlerStream, that implement the abstract virtual methods of this ancestor class.

TIdIOHandler specifies the methods normally used create and bind a client connection, determine when an IOHandler is ready to perform an IO operation, and perform the data transmission or receipt required for the component.

TIdIOHandler.AfterAccept
TIdIOHandler, See Also
Specifies the method used to initialize an IOHandler after a new connection request.

    procedure AfterAccept; virtual;

Description
AfterAccept is a virtual procedure in TIdIOHandler that specifies the mechanism used to initialize an IOHandler after a listener thread for has detected a client connection request. AfterAccept must be implemented in a descendant class, like TIdSSLIOHandlerSocket, to allow any operation needed prior to calling Accept for the socket binding in the newly detected client connection.

TIdIOHandler.Close
TIdIOHandler, See Also
Closes the input/output source for the handler.

    procedure Close; virtual;

Description
Close is a virtual procedure that performs the processing necessary to close an input/output source. Descendant classes must override this method to provide the specific functionality needed for the IOHandler, such as closing a socket handle or stream.

TIdIOHandler.ConnectClient
TIdIOHandler, See Also
Establisheds a remote connection for the input/output handler.

    procedure ConnectClient(const AHost: string; const APort: Integer; const ABoundIP: string; const ABoundPort: Integer; const ABoundPortMin: Integer; const ABoundPortMax: Integer; const ATimeout: Integer = IdTimeoutDefault); virtual;

Parameters
const AHost: string
Address of the remote system for the client connection.
const APort: Integer
Port number for the remote connection.
const ABoundIP: string
IP Address bound to the local system.
const ABoundPort: Integer
Port number bound to the local computer.
const ABoundPortMin: Integer
Minimum bound port number for the local system.
const ABoundPortMax: Integer
Maximum bound port number for the local system.
const ATimeout: Integer = IdTimeoutDefault
Number of milliseconds to wait before a connection attempt fails. Default value is IdTimeoutDefault.
Description
ConnectClient is a virtual procedure in TIdIOHandler that specifies the mechanism that allows an input/output handler to prepare and establish a client connection to a remote computer system using the input parameters. ConnectClient must be implemented in a TIdIOHandler decendant, like TIdIOHandlerSocket or TIdSSLIOHandlerSocket, that uses a physical connection to a remote system.

TIdIOHandler.Connected
TIdIOHandler, See Also
Indicates if the IOHandler connection is prepared and opened.

    function Connected: Boolean; virtual; abstract;

Return Value
Boolean - True when the IOHandler connection is prepared and opened.
Description
Connected is an abstract virtual Boolean function in TIdIOHandler that specifies the method to be used to determine when the physical connection for the IOHandler has been established. TIdIOHandler descendant classes must implement Connected to indicate when the connection is available for input/output operations.

For Socket-based IOHandlers, like TIdIOHandlerSocket and TIdSSLIOHandlerSocket, Connected will indicate when the socket handle in Binding has been allocated.

For Stream-based IOHandlers, like TIdIOHandlerStream, Connected will indicate when the read and/or write stream has been assigned for the corresponding stream type.

Use Open to prepare the physical connection for the IOHandler, and ConnectCLient to establish the connection used by the IOHandler.

TIdIOHandler.Destroy
TIdIOHandler, See Also
Destructor for the object instance.

    destructor Destroy; override;

Description
Destroy is the Destructor for the object instance. Destroy calls the Close method prior to calling the inherited Destructor.

TIdIOHandler.Open
TIdIOHandler, See Also
Prepares an input/output source for the handler.

    procedure Open; virtual;

Description
Open is a virtual procedure that prepares an input/output source for the IOHandler. Open is used in descendant classes to prepare the socket handle used for a connection to a remote computer system.

TIdIOHandler.Readable
TIdIOHandler, See Also
Indicates when the input/output source is ready.

    function Readable(AMSec: Integer = IdTimeoutDefault): Boolean; virtual; abstract;

Parameters
AMSec: Integer = IdTimeoutDefault
Milliseconds to wait for an the input/output source to become available. Default value is IdTimeoutDefault.
Return Value
Boolean - True when the input/output source is ready.
Description
Readable is an abstract virtual Boolean function that indicates when the input/output source for the IO handler is ready to perform the desired operation. Descendant classes must override this method to indicate when the underlying socket handle or stream is available.

TIdIOHandler.Recv
TIdIOHandler, See Also
Reads data from an input source.

    function Recv(var ABuf; ALen: Integer): Integer; virtual; abstract;

Parameters
var ABuf
Destination buffer for values read from the input source.
ALen: Integer
Number of bytes to read from the input source.
Return Value
Integer - Number of bytes read.
Description
Recv is an abstract virtual Integer function that performs a read operation on an input source. Values read by the handler are stored in ABuf. ALen indicates the numbers of bytes expected in the read operation. The return value for the method is the actual number of bytes read from the input source.

Descendant classes must override this method to implement the specific functionality required to read data from the underlying socket handle or stream.

TIdIOHandler.Send
TIdIOHandler, See Also
Sends data to an output source.

    function Send(var ABuf; ALen: Integer): Integer; virtual; abstract;

Parameters
var ABuf
Buffer containing values to be written.
ALen: Integer
Number of bytes to b written.
Return Value
Integer - Number of bytes written.
Description
Send is an abstract virtual Integer function that performs a write operation on an output destination. Values written by the handler are stored in ABuf. ALen indicates the numbers of bytes expected in the write operation. The return value for the method is the actual number of bytes written to the output destination.

Descendant classes must override this method to implement the specific functionality required to write data to the underlying socket handle or stream.

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