unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, idContext, StdCtrls, IdCustomTCPServer, IdTCPServer, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient;
type
TForm1 =
class(TForm)
IdTCPClient1: TIdTCPClient;
IdTCPServer1: TIdTCPServer;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit3: TEdit;
Button2: TButton;
Label3: TLabel;
ListBox1: TListBox;
Edit4: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure IdTCPServer1Execute(AContext: TIdContext);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
IdTCPServer1.Active:= False;
IdTCPServer1.DefaultPort:=StrToInt(Edit4.Text);
IdTCPServer1.Active:= True;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with IdTCPClient1
do
try
Host := Edit1.Text;;
Port := StrToInt(Edit2.Text);
Connect;
ShowMessage('
Connected.');
try
IdTCPClient1.IOHandler.WriteLn(Edit3.Text);
ShowMessage('
Gesendet.');
finally
Disconnect;
ShowMessage('
Disconnected.');
end;
finally
end;
end;
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
begin
ListBox1.Items.Add(AContext.Connection.IOHandler.ReadLn);
end;