unit AllInOne;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdCustomTCPServer, IdTCPServer, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, idContext, StdCtrls;
type
TForm1 =
class(TForm)
IdTCPClient1: TIdTCPClient;
IdTCPServer1: TIdTCPServer;
Memo1: TMemo;
Button1: TButton;
procedure IdTCPServer1Execute(AThread: TIdPeerThread);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
IdTCPServer1.Active := False;
IdTCPServer1.Bindings.Clear;
IdTCPServer1.DefaultPort := Portadresse;
try
IdTCPServer1.Active := True;
except
Raise;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s :
String ;
begin
IdTCPClient1.Host := Hostadresse;
IdTCPClient1.Port := Portadresse;
IdTCPClient1.Connect;
if IdTCPClient1.Connected
then begin
IdTCPClient1.IOHandler.WriteLn('
Dies ist eine Nachricht vom Client.');
s := IdTCPClient1.IOHandler.ReadLnWait(1000) ;
IdTCPClient1.disconnect ;
end;
Memo1.lines.Add ( S ) ;
end;
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
begin
with AThread.Connection
do begin
Memo1.Lines.Add ( '
Server ist Bereit');
Memo1.Lines.Add('
Nachricht von Client: ' ReadLn );
AThread.Connection.WriteLn( '
Nachricht wurde erfolgreich übermittelt');
Disconnect;
end;
end;
end.