Class TClientWSocket (unit ApSrvCli)

Inherits from

TCustomWSocket

:TClientWSocket is a specialized TWSocket which handle a single client connected to the application server. TAppServer component instanciate a new TClientWSocket for each new client connectiong to the server.

Constructors


constructor Create(AOwner: TComponent);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Functions

procedure CheckCommandTimeout;

:Procedure used by TAppServer to chack for inactivity timeout.

destructor Destroy;

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

procedure SendReply;

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

procedure StartConnection;

:First method to be invoked on client connection.

procedure Dup(newHSocket : TSocket);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

function GetPeerAddr: string;

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

procedure SetRcvSize(newValue : Integer);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

procedure TriggerCommand(CmdBuf : PChar; CmdLen : Integer);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

function TriggerDataAvailable(Error : Word) : boolean;

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

procedure TriggerSessionConnected(Error : Word);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

procedure TriggerTimeout(var CanClose : Boolean);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Properties

property Banner : String

:The banner to be sent to the client upon connection.

property Busy : Boolean

:Tells if the previous request is still executing.

property HSocket :

:Inherited property giving the winsock handle.

property RcvSize : integer

:Size of buffer used to receive commands (requests).

property UserData : LongInt

:UserData is not user by MidWare, it is left for the application programmer use.

property CommandCount : LongInt

:Number of commands issued by the client.

property CommandTimeOut : TDateTime

:Timeout value.

property ConnectedSince : TDateTime

:Gives the time when the client connected.

property LastCommandTime : TDateTime

:Gives the time of the last command received.

property PeerAddr : String

:Store the client's IP address.

property RcvdCount :

:Inherited property giving the number of bytes received.

property ReplyBody : PChar

:ReplyBody point to the answer to be sent to the client.

property ReplyBodyLen : Integer

:ReplyBodyLen is the length in bytes for the answer.

property ReplyHeader : PChar

:ReplyHeader point to the header built by the AppServer based on reply status.

property ReplyHeaderLen : Integer

:ReplyHeaderLen is the length in byte for the header.

Events

event OnCommand : TCommandEvent

:Triggered when a client request (command) is received.

event OnDisplay : TDisplayEvent

:Triggered when the component wants to display something on the user interface.

event OnSessionClosed :

:Inherited event triggered when the client disconnect.

event OnTimeout : TTimeoutEvent

:Triggered when the client timedout as is about to be disconnected by TAppServer.

Variables

FBanner : String;


FBusy : Boolean;


FCommandCount : LongInt;


FCommandTimeOut : TDateTime;


FConnectedSince : TDateTime;


FLastCommandTime : TDateTime;


FOnCommand : TCommandEvent;


FOnDisplay : TDisplayEvent;


FOnTimeout : TTimeoutEvent;


FPeerAddr : String;


FRcvBuf : PChar;


FRcvCnt : Integer;


FRcvSize : Integer;


FReplyBody : PChar;


FReplyBodyLen : Integer;


FReplyHeader : PChar;


FReplyHeaderLen : Integer;


FUserData : LongInt;



Constructors


constructor Create(AOwner: TComponent);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Functions


procedure CheckCommandTimeout;

:Procedure used by TAppServer to chack for inactivity timeout.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


destructor Destroy;

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


procedure SendReply;

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


procedure StartConnection;

:First method to be invoked on client connection. It initializes internal working and send the banner to the client.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


procedure Dup(newHSocket : TSocket);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


function GetPeerAddr: string;

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


procedure SetRcvSize(newValue : Integer);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


procedure TriggerCommand(CmdBuf : PChar; CmdLen : Integer);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


function TriggerDataAvailable(Error : Word) : boolean;

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


procedure TriggerSessionConnected(Error : Word);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


procedure TriggerTimeout(var CanClose : Boolean);

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Properties


property Banner : String

:The banner to be sent to the client upon connection.


property Busy : Boolean

:Tells if the previous request is still executing.


property HSocket :

:Inherited property giving the winsock handle.


property RcvSize : integer

:Size of buffer used to receive commands (requests).


property UserData : LongInt

:UserData is not user by MidWare, it is left for the application programmer use.


property CommandCount : LongInt

:Number of commands issued by the client.


property CommandTimeOut : TDateTime

:Timeout value. If the client stay inactive for this period of time, the server will disconnect it.


property ConnectedSince : TDateTime

:Gives the time when the client connected.


property LastCommandTime : TDateTime

:Gives the time of the last command received. Use for timeout.


property PeerAddr : String

:Store the client's IP address. The value is cached.


property RcvdCount :

:Inherited property giving the number of bytes received.


property ReplyBody : PChar

:ReplyBody point to the answer to be sent to the client.


property ReplyBodyLen : Integer

:ReplyBodyLen is the length in bytes for the answer.


property ReplyHeader : PChar

:ReplyHeader point to the header built by the AppServer based on reply status.


property ReplyHeaderLen : Integer

:ReplyHeaderLen is the length in byte for the header.


Events


event OnCommand : TCommandEvent

:Triggered when a client request (command) is received.


event OnDisplay : TDisplayEvent

:Triggered when the component wants to display something on the user interface.


event OnSessionClosed :

:Inherited event triggered when the client disconnect.


event OnTimeout : TTimeoutEvent

:Triggered when the client timedout as is about to be disconnected by TAppServer.


Variables


FBanner : String;


FBusy : Boolean;


FCommandCount : LongInt;


FCommandTimeOut : TDateTime;


FConnectedSince : TDateTime;


FLastCommandTime : TDateTime;


FOnCommand : TCommandEvent;


FOnDisplay : TDisplayEvent;


FOnTimeout : TTimeoutEvent;


FPeerAddr : String;


FRcvBuf : PChar;


FRcvCnt : Integer;


FRcvSize : Integer;


FReplyBody : PChar;


FReplyBodyLen : Integer;


FReplyHeader : PChar;


FReplyHeaderLen : Integer;


FUserData : LongInt;