Indy 9 | Content | Index | Reference

TIdConnectionIntercept
Hierarchy, Properties, Methods, Events, See Also, Unit: IdIntercept
Specifies a socket handling framework that performs state change and data transformation tasks.

    TIdConnectionIntercept = class(TIdBaseComponent)

Unit
IdIntercept
Description
TIdConnectionIntercept is an abstract class that implements a generic framework for servicing sockets during operations that affect the state of the connection, or perform input and output over the socket binding.

TIdConnectionIntercept descendants can be used by TIdTCPConnection and descendants to act as an intermediary between the socket binding for the connection and low-level operations that communicate with the protocol stack.

TIdConnectionIntercept provides virtual methods to respond to Connect and Disconnect requests for a socket binding by capturing or releasing a reference to the TIdSocketHandle used by the protocol stack.

The socket handle will be used to access data before messages are sent and/or after responses are received. Developers can use TIdConnectionIntercept descendants to encrypt and decrypt data, or to compress and decompress messages.

Additional virtual methods can be used to perform the Send or Recv operation in behalf of the original socket connection. TIdConnectionIntercept can also allow the socket connection to complete the input/output operation by changing the SendHandling and ReceiveHandling properties.

Note: Do not create instances of TIdConnectionIntercept. Use descendant classes, like TIdConnectionInterceptOpenSSL or TIdLogDebug, or create custom descendants that implement the virtual methods of TIdConnectionIntercept.

TIdConnectionIntercept.Connection
TIdConnectionIntercept, See Also
Socket descriptor to be arbitrated by the connection intercept.

    property Connection: TComponent;

Description
Connection is a read-only TComponent property that represents the low-level socket descriptor that will be arbitrated using methods in the TIdConnectionIntercept framework. Connection is assigned in the Connect method, and released in the Disconnect method.

TIdConnectionIntercept.IsClient
TIdConnectionIntercept, See Also
Indicates that the socket handler is for a client connection.

    property IsClient: Boolean;

Description
IsClient is a read-only Boolean property that indicates the socket intercept handler is for a client connection. The default value for IsClient is True, as assigned in the Create constructor.

TIdConnectionIntercept.Connect
TIdConnectionIntercept, See Also
Responds to connection notifications.

    procedure Connect(AConnection: TComponent); virtual;

Parameters
ABinding
Socket handle for the connection.
Description
Connect is procedure used to inform the TIdConnectionIntercept that the socket has successfully completed a connection. ABinding is the TIdSocketHandle socket descriptor that generates the connection notification, and is stored in Binding.

Connect generates a TNotifyEvent event when the OnConnect event handler has been assigned to respond to the connection event.

Connect is a virtual method in TIdConnectionIntercept, and can be re-implemented in descendant classes to provide additional connection handling appropriate to the socket handler.

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

    constructor Create(AOwner: TComponent); override;

Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create is the construcor for the object instance. Create call the inherited Create method using AOwner as the owner of the object instance. Create also assigns True as the default value for the IsClient property.

TIdConnectionIntercept.Disconnect
TIdConnectionIntercept
Responds to socket disconnection notifications.

    procedure Disconnect; virtual;

Description
Disconnect is a procedure that allows TIdConnectionIntercept to respond to notification the socket connection is Binding is closing.

Disconnect is a virtual method that sets the value of Binding, assigned in the Connect method, to Nil. Clearing the reference in Binding will prevent further socket notifications to the socket handler.

TIdConnectionIntercept descendants should implement Disconnect to perform the operations appropriate to the socket handler.

TIdConnectionIntercept.Receive
TIdConnectionIntercept, See Also, Example
Performs read operations for the socket handler.

    procedure Receive(ABuffer: TStream); virtual;

Parameters
ABuf
Pointer to the buffer for received data.
ALen
Number of bytes to read, or size of the memory buffer.
Return Value
Integer - Number of bytes received. Default Value is 0.
Description
Receive is an Integer function that performs read operations for the Binding that represents the socket connection. When the TIdConnectionIntercept component is enabled and RecvHandling is indicated, Receive is the method used to perform all read operations instead of the Receive method for the Binding.

Receive is used in conjunction with DataReceived to allow the TIdConnectionIntercept to perform transformations for any data read from the protocol stack.

Note: Receive is a virtual method in TIdConnectionIntercept and always returns 0 as the result value. Descendant classes should implement Receive to perform socket read operations appropriate for the socket handler.

TIdConnectionIntercept.Send
TIdConnectionIntercept, Example
Performs send operations for the socket handler.

    procedure Send(ABuffer: TStream); virtual;

Parameters
ABuf
Pointer to the buffer for data to send.
ALen
Number of bytes to send, or size of the memory buffer.

Return Values:

Integer - Number of bytes sent. Default Value is 0.

Description
Send is an Integer function that performs write operations for the Binding that represents the socket connection. When the TIdConnectionIntercept component is enabled and SendHandling is indicated, Send is the method used to perform all write operations instead of the Send method for the Binding.

Send is used in conjunction with DataSent to allow the TIdConnectionIntercept to perform transformations for any data written to the protocol stack.

Note: Send is a virtual method in TIdConnectionIntercept and always returns 0 as the result value. Descendant classes should implement Send to perform socket write operations appropriate for the socket handler.

TIdConnectionIntercept.OnConnect
TIdConnectionIntercept, See Also
Specifies the event handler for connection notifications.

    property OnConnect: TIdInterceptNotifyEvent;

Parameters
ABinding
Socket handle for the peer connection.
Description
OnConnect is a TNotifyEvent property that is the event handler for connection notifications received by the TIdConnectionIntercept socket handler.

ABinding is the TIdSocketHandle socket handle for the peer connection, and is stored in Binding for use during read and write operations.

Assign a procedure to OnConnect to perform special processing when a connection notification is received in the Connect method. Applications must assign an OnConnect event handler in order to respond to connection notifications.

TIdConnectionIntercept.OnDisconnect
TIdConnectionIntercept, See Also
Event handler signalled when the connection is closing.

    property OnDisconnect: TIdInterceptNotifyEvent;

Description
OnDisconnect is a TIdInterceptNotifyEvent property that represents the event handler signalled when the arbitrated socket descriptor in Connection should be closed. OnDisconnect is triggered in Disconnect prior to releasing the valuein Connection.

Applications must assign a procedure to the TIdInterceptNotifyEvent event handler to allow responding to the event notification.

TIdConnectionIntercept.OnReceive
TIdConnectionIntercept, See Also
Allows data handling or transformation for intercepted read operations.

    property OnReceive: TIdInterceptStreamEvent;

Description
OnReceive is a TIdInterceptStreamEvent property that represents the event handler signalled when a read operation needs to be performed for the socket descriptor in Connection. OnReceive is triggered in the Receive method, and allows handling or transformation of buffered data in a TStream instance.

Applications must assign a procedure to the TIdInterceptStreamEvent event handler to allow responding to the event notification.

TIdConnectionIntercept.OnSend
TIdConnectionIntercept, See Also
Allows data handling or transformation for intercepted write operations.

    property OnSend: TIdInterceptStreamEvent;

Description
OnSend is a TIdInterceptStreamEvent property that represents the event handler signalled when a write operation needs to be performed for the socket descriptor in Connection. OnSend is triggered in the Send method, and allows handling or transformation of buffered data in a TStream instance.

Applications must assign a procedure to the TIdInterceptStreamEvent event handler to allow responding to the event notification.

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