Difference between revisions of "Midware TClientWSocket"

From Overbyte
Jump to navigation Jump to search
(Created page with ' Main page -> Midware component reference -> TClientWSocket == Overview == {| | '''unit''' ||…')
 
 
(14 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
|}
 
|}
  
TClientWSocket is a specialized TWSocket used to handle client connection with application server. A new TClientWSocket is instanciated by TAppServer when a client connect to the server. TClientWSocket is destroyed after client disconnect.
+
TClientWSocket is a specialized TWSocket used to handle client connection with application server. A new TClientWSocket is instanciated by [[Midware_TAppServer | TAppServer]] when a client connect to the server. TClientWSocket is destroyed after client disconnect.
  
Do not confuse TClientWSocket with TAppSrvClient which is the client application side. TClientWSocket is used on the server side to handle client connections, TAppSrvClient is used on the client side to connect to the application server. Both components are talking to each other.
+
Do not confuse TClientWSocket with [[Midware_TAppSrvClient | TAppSvrClient]] which is the client application side. TClientWSocket is used on the server side to handle client connections, [[Midware_TAppSrvClient | TAppSvrClient]] is used on the client side to connect to the application server. Both components are talking to each other.
 +
 
 +
User code in an ordinary application server never create a TClientWSocket instance. Instead, it uses instances created by [[Midware_TAppServer | TAppServer]] and accessed thru his ClientWSocket indexed property or thru reference passed by events such as OnClientCommand.
  
User code in an ordinary application server never create a TClientWSocket instance. Instead, it uses instances created by TAppServer and accessed thru his ClientWSocket indexed property or thru reference passed by events such as OnClientCommand.
 
 
== Properties ==
 
== Properties ==
 
{|  
 
{|  
Line 21: Line 22:
 
| valign="top" | [[Midware_TClientWSocket.CommandTimeout | CommandTimeout]] |||| Timeout value.
 
| valign="top" | [[Midware_TClientWSocket.CommandTimeout | CommandTimeout]] |||| Timeout value.
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.ConnectedSinze | ConnectedSinze]] |||| Gives the time when the client connected.         
+
| valign="top" | [[Midware_TClientWSocket.ConnectedSince | ConnectedSince]] |||| Gives the time when the client connected.         
 
|-
 
|-
 
| valign="top" | [[Midware_TClientWSocket.HSocket | HSocket]] |||| HSocket is the underlaying winsock DLL handle for the connection handled by TClientWSocket component.
 
| valign="top" | [[Midware_TClientWSocket.HSocket | HSocket]] |||| HSocket is the underlaying winsock DLL handle for the connection handled by TClientWSocket component.
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.Request | Request]] |||| The request property holds the parameters sent to the application server.  
+
| valign="top" | [[Midware_TClientWSocket.LastCommandTime | LastCommandTime]] |||| Gives the time of the last command received from client.
 +
|-
 +
| valign="top" | [[Midware_TClientWSocket.LocalPort | LocalPort]] |||| LocalPort gives the port number (or service name) associated by winsock on the local computer for the connection made by client.
 +
|-
 +
| valign="top" | [[Midware_TClientWSocket.PeerAddr | PeerAddr]] |||| Store the client's IP address.
 +
|-
 +
| valign="top" | [[Midware_TClientWSocket.RcvBuf | RcvBuf]] |||| The actual buffer used to store incomming data.
 +
|-
 +
| valign="top" | [[Midware_TClientWSocket.RcvdCount | RcvdCount]] |||| Returns the number of characters received and not yet read.
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.RequestBody | RequestBody]] |||| RequestBody gives the address where the message body is stored just before sending it to the application server.  
+
| valign="top" | [[Midware_TClientWSocket.RcvSize | RcvSize]] |||| Size of buffer used to receive commands (requests).
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.RequestBodyLen | RequestBodyLen]] |||| RequestBodyLen gives the message body length just before sending it to the application server.
+
| valign="top" | [[Midware_TClientWSocket.RcvSizeInc | RcvSizeInc]] |||| When RcvBuf is too small, it will be enlarged by RcvSizeInc bytes automatically until RcvSizeMax is reached.
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.RequestHeader | RequestHeader]] |||| RequestHeader gives the address where the message header is stored just before sending it to the application server.
+
| valign="top" | [[Midware_TClientWSocket.RcvSizeMax | RcvSizeMax]] |||| When RcvBuf is too small, it will be enlarged by RcvSizeInc bytes automatically until RcvSizeMax is reached.
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.RequestHeaderLen | RequestHeaderLen]] |||| RequestHeaderLen gives the message header length just before sending it to the application server.
+
| valign="top" | [[Midware_TClientWSocket.ReplyHeader | ReplyHeader]] |||| ReplyHeader point to the header built by the [[Midware_TAppServer | TAppServer]] based on reply status.
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.Server | Server]] |||| This is the IP address or hostname for the application server.  
+
| valign="top" | [[Midware_TClientWSocket.ReplyHeaderLen | ReplyheaderLen]] |||| ReplyHeaderLen is the length in byte for the header.  
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.SocksAuthentication | SocksAuthentication]] |||| SocksAuthentication specifies which socks5 authentication method to use.
+
| valign="top" | [[Midware_TClientWSocket.ReplyBody | ReplyBody]] |||| ReplyBody point to the answer to be sent to the client.
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.SocksPassword | SocksPassword]] |||| SocksPassword is the password used for Socks5 connection.
+
| valign="top" | [[Midware_TClientWSocket.ReplyBodyLen | ReplyBodyLen]] |||| ReplyBodyLen is the length in bytes for the answer.  
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.SocksPort| SocksPort]] |||| Socks5 port number.
+
| valign="top" | [[Midware_TClientWSocket.UserData | UserData]] |||| UserData is not used by the component nor the [[Midware_TAppServer | TAppServer]] component.
 +
|}
 +
 
 +
== Methods ==
 +
 
 +
{|
 +
| width="140" valign="top" | [[Midware_TClientWSocket.CheckCommandTimeout | CheckCommandTimeout]] |||| Procedure used by [[Midware_TAppServer | TAppServer]] to check for inactivity timeout.
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.SocksServer | SocksServer]] |||| IP or hostname for socks5 server.
+
| valign="top" | [[Midware_TClientWSocket.Dup | Dup]] |||| Dup associate a winsock handle to a TClientWSocket component.  
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.SocksUsercode | SocksUsercode]] |||| Socks5 usercode.
+
| valign="top" | [[Midware_TClientWSocket.GetPeerAddr | GetPeerAddr]] ||||  
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.State | Stade]] |||| State property gives the component state:
+
| valign="top" | [[Midware_TClientWSocket.SendReply | SendReply]] |||| SendReply procedure will send ReplyHeader and About MidWare followed by a CR/LF pair.
 
|-
 
|-
| valign="top" | [[Midware_TClientWSocket.WSocket | WSocket]] |||| WSocket is the reference to the underlaiying TWSocket component used for communication with the application server.
+
| valign="top" | [[Midware_TClientWSocket.StartConnection | StartConnection]] |||| First method to be invoked on client connection.
 
|-
 
|-
 
|}
 
|}
 +
 +
== Events ==
 +
 +
{|
 +
| width="140" valign="top" | [[Midware_TClientWSocket.OnBgException | OnBgException]] |||| Occurs when an exception is thrown in the background.
 +
|-
 +
| valign="top" | [[Midware_TClientWSocket.OnCommand | OnCommand]] |||| Occurs when a command has been received from client.
 +
|-
 +
| valign="top" | [[Midware_TClientWSocket.OnDisplay | OnDisplay]] |||| Occurs when a message has to be displayed on the user interface.
 +
|-
 +
| valign="top" | [[Midware_TClientWSocket.OnOverflow | OnOverflow]] |||| Occurs when the input buffer is overflowed and can't be enlarged.
 +
|-
 +
| valign="top" | [[Midware_TClientWSocket.OnSessionClosed | OnSessionClosed]] |||| Occurs when client disconnect from server.
 +
|-
 +
| valign="top" | [[Midware_TClientWSocket.OnTimeout | OnTimeout]] |||| Occurs when client will be disconnected because of no activity.
 +
|}
 +
 +
== How to ==
 +
 +
{{Midware_Components_Footer}}

Latest revision as of 15:25, 24 May 2011

Main page -> Midware component reference -> TClientWSocket

Overview

unit ApSrvCli.pas

TClientWSocket is a specialized TWSocket used to handle client connection with application server. A new TClientWSocket is instanciated by TAppServer when a client connect to the server. TClientWSocket is destroyed after client disconnect.

Do not confuse TClientWSocket with TAppSvrClient which is the client application side. TClientWSocket is used on the server side to handle client connections, TAppSvrClient is used on the client side to connect to the application server. Both components are talking to each other.

User code in an ordinary application server never create a TClientWSocket instance. Instead, it uses instances created by TAppServer and accessed thru his ClientWSocket indexed property or thru reference passed by events such as OnClientCommand.

Properties

Banner The banner to be sent to the client upon connection. Must be a single line.
Busy Busy is TRUE while a the previous request is still executing.
CommandCount Number of commands issued by the client. Useful for statistics or accounting purposes.
CommandTimeout Timeout value.
ConnectedSince Gives the time when the client connected.
HSocket HSocket is the underlaying winsock DLL handle for the connection handled by TClientWSocket component.
LastCommandTime Gives the time of the last command received from client.
LocalPort LocalPort gives the port number (or service name) associated by winsock on the local computer for the connection made by client.
PeerAddr Store the client's IP address.
RcvBuf The actual buffer used to store incomming data.
RcvdCount Returns the number of characters received and not yet read.
RcvSize Size of buffer used to receive commands (requests).
RcvSizeInc When RcvBuf is too small, it will be enlarged by RcvSizeInc bytes automatically until RcvSizeMax is reached.
RcvSizeMax When RcvBuf is too small, it will be enlarged by RcvSizeInc bytes automatically until RcvSizeMax is reached.
ReplyHeader ReplyHeader point to the header built by the TAppServer based on reply status.
ReplyheaderLen ReplyHeaderLen is the length in byte for the header.
ReplyBody ReplyBody point to the answer to be sent to the client.
ReplyBodyLen ReplyBodyLen is the length in bytes for the answer.
UserData UserData is not used by the component nor the TAppServer component.

Methods

CheckCommandTimeout Procedure used by TAppServer to check for inactivity timeout.
Dup Dup associate a winsock handle to a TClientWSocket component.
GetPeerAddr
SendReply SendReply procedure will send ReplyHeader and About MidWare followed by a CR/LF pair.
StartConnection First method to be invoked on client connection.

Events

OnBgException Occurs when an exception is thrown in the background.
OnCommand Occurs when a command has been received from client.
OnDisplay Occurs when a message has to be displayed on the user interface.
OnOverflow Occurs when the input buffer is overflowed and can't be enlarged.
OnSessionClosed Occurs when client disconnect from server.
OnTimeout Occurs when client will be disconnected because of no activity.

How to


Midware Components Reference