Indy 9
|
TIdSimpleServer = class(TIdTCPConnection)
TIdSimpleServer can be used as a base class to create custom single-threaded TCP server descendants.
property AcceptWait: integer;
AcceptWait is used in Listen to determine if the TIdSocketHandle allocated to Binding is readable.
property Binding: TIdSocketHandle;
Binding is allocated in the CreateBinding method.
Binding is used when TIdSimpleServer begins to listen for connection requests. If Binding is not assigned, ResetConnection is called and the Binding is initialized using CreateBinding.
Binding is also used when the socket handle for the specified BoundIP and BoundPort is bound in the Bind method.
property BoundIP: string;
BoundIP exists because Binding is not a published property (it is public) and cannot be streamed without the TIdSocketHandles collection that owns the Binding.
property BoundPort: Integer;
BoundPort exists because Binding is not a published property, it is public, and cannot be streamed without the TIdSocketHandles collection that owns the Binding.
property ListenHandle: TIdStackSocketHandle;
procedure Abort; virtual;
procedure BeginListen; virtual;
BeginListen calls ResetConnection to clear the internal flags used by the server. BeginListen calls the Listen method for Binding and sets the internal flag that indicates that the server is listening for client connections.
BeginListen is called from Listen prior to entering the control loop for the listener.
procedure Bind; virtual;
ListenHandle will contain the handle for the Binding. If an exception occurs, ListenHandle is assigned the value Id_INVALID_SOCKET and the exception is raised.
constructor Create(AOwner: TComponent); override;
procedure CreateBinding;
CreateBinding is called from the BeginListen method, to prepare the server to accept connection requests.
procedure EndListen; virtual;
function Listen: Boolean; virtual;
Listen call BeginListen to initialize the server socket handle and state prior to entering the listener thread of execution. Listen provides a control loop that uses both AbortRequested and the socket handle Binding to determine when the server should stop listening for a client connection.
While AbortRequested is False, Listen will insure that the Binding is readable using the AcceptWait timeout value. When a connection request is detected, Listen calls Accept using the Handle for Binding.
When AbortRequested is True or a new connection has handled with Accept, Listen will close and invalidate the socket handle in ListenHandle.
procedure ResetConnection; override;