unit foServerClient;
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(AContext: TIdContext);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
s :
String ;
begin
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(AContext: TIdContext);
begin
if not aContext.Connection.IOHandler.Readable
then
exit ;
Memo1.Lines.Add('
Nachricht: ' + AContext.Connection.IOHandler.ReadLn);
AContext.Connection.IOHandler.WriteLn('
OK und hier ist die Antwort.');
end;