unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient;
type
TForm1 =
class(TForm)
TCPClient: TIdTCPClient;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
private
Procedure SendM(S:
String);
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Procedure TForm1.SendM(S:
String);
begin
if TCPClient.Connected
then
begin
TCPClient.IOHandler.WriteLn(S);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TCPClient.Connect;
SendM('
Dies ist eine Nachricht vom Clienten.');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
TCPClient.Disconnect;
end;
procedure TForm1.Edit1KeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
case Key
of
vk_Return:SendM(Edit1.Text);
end;
end;
end.