unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, glSpeedButton, IdTCPConnection, IdTCPClient,
IdBaseComponent, IdComponent, IdTCPServer, StdCtrls;
type
TForm1 =
class(TForm)
IdTCPServer1: TIdTCPServer;
IdTCPClient1: TIdTCPClient;
glSpeedButton1: TglSpeedButton;
glSpeedButton2: TglSpeedButton;
servermemo: TMemo;
clientmemo: TMemo;
Button1: TButton;
Button2: TButton;
procedure glSpeedButton1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure glSpeedButton2Click(Sender: TObject);
procedure IdTCPServer1Connect(AThread: TIdPeerThread);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure IdTCPServer1TIdCommandHandler1Command(ASender: TIdCommand);
procedure IdTCPServer1TIdCommandHandler0Command(ASender: TIdCommand);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.glSpeedButton1Click(Sender: TObject);
begin
IdTCPServer1.Active:=True;
Form1.Caption:='
Server';
servermemo.Visible:=True;
end;
procedure TForm1.glSpeedButton2Click(Sender: TObject);
begin
glSpeedButton2.Enabled:=False;
IdTCPClient1.Connect();
Form1.Caption:='
Client';
clientmemo.Visible:=True;
Button1.Visible:=True;
Button2.Visible:=True;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if IdTCPServer1.Active
then IdTCPServer1.Active:=False;
if IdTCPClient1.Connected
then IdTCPClient1.Disconnect;
end;
procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread);
begin
servermemo.Lines.Add('
Client verbunden');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
IdTCPClient1.SendCmd('
test');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
IdTCPClient1.WriteLn('
test');
end;
procedure TForm1.IdTCPServer1TIdCommandHandler0Command(
ASender: TIdCommand);
begin
showmessage('
Command2');
end;
procedure TForm1.IdTCPServer1TIdCommandHandler1Command(
ASender: TIdCommand);
begin
showmessage('
Command1');
end;
end.