unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, IdTCPClient, IdBaseComponent, IdComponent,
IdTCPConnection, IdSimpleServer;
type
TForm1 =
class(TForm)
IdSimpleServer1: TIdSimpleServer;
IdTCPClient1: TIdTCPClient;
Button1: TButton;
ProgressBar1: TProgressBar;
CheckBox1: TCheckBox;
Edit1: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure IdSimpleServer1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure IdSimpleServer1WorkBegin(Sender: TObject;
AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure IdSimpleServer1Status(ASender: TObject;
const AStatus: TIdStatus;
const AStatusText:
String);
procedure IdSimpleServer1Disconnected(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if IdTCPClient1.Connected
then begin
IdTCPClient1.Disconnect;
Button1.Caption := '
0';
end else begin
IdTCPClient1.Connect(2500);
if IdTCPClient1.Connected
then
Button1.Caption := '
1'
else
Button1.Caption := '
0';
end;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked
then
IdSimpleServer1.Listen
else
IdSimpleServer1.EndListen;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if IdTCPClient1.Connected
then
IdTCPClient1.WriteLn(Edit1.Text);
end;
procedure TForm1.IdSimpleServer1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
Caption := IdSimpleServer1.ReadLn(#$A, 2500);
end;
procedure TForm1.IdSimpleServer1WorkBegin(Sender: TObject;
AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
var
i : Integer;
begin
i := 0;
end;
procedure TForm1.IdSimpleServer1Status(ASender: TObject;
const AStatus: TIdStatus;
const AStatusText:
String);
var
i : Integer;
begin
i := 0;
end;
procedure TForm1.IdSimpleServer1Disconnected(Sender: TObject);
begin
IdSimpleServer1.EndListen;
CheckBox1.Checked := false;
end;
end.