unit Grundclient;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls;
type
TForm1 =
class(TForm)
Bt_Senden: TButton;
Edit1: TEdit;
Edit2: TEdit;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure OnRead(Sender: TObject; Socket: TCustomWinSocket);
procedure Bt_SendenClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
myClient : TClientSocket;
implementation
{$R *.dfm}
procedure TForm1.OnRead(Sender: TObject; Socket: TCustomWinSocket);
begin
Memo1.Lines.Add('
Daten vom Server');
Memo1.Lines.Add(Socket.ReceiveText);
end;
procedure TForm1.Bt_SendenClick(Sender: TObject);
begin
myClient.Host := '
localhost';
myClient.Active := True;
if myClient.active=true
then
begin
myClient.Socket.SendText(edit2.text);
Memo1.Lines.Add('
Nachricht gesendet');
Memo1.Lines.Add(edit2.text);
end;
edit2.text:='
'
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Text := '
Client getrennt';
myClient := TClientSocket.Create(self);
myClient.Port := 6712;
myClient.OnRead := self.OnRead;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
myClient.Free;
end;
end.