unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, XPMan, StdCtrls, ScktComp, ExtCtrls;
type
TForm1 =
class(TForm)
Client: TClientSocket;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Button1: TButton;
Label1: TLabel;
Button2: TButton;
GroupBox3: TGroupBox;
Button3: TButton;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Label4: TLabel;
Edit3: TEdit;
Button4: TButton;
Memo1: TMemo;
XPManifest1: TXPManifest;
Server: TServerSocket;
Button5: TButton;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ServerClientRead(Sender: TObject; Socket: TCustomWinSocket);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Delay(time: word);
procedure ClientRead(Sender: TObject; Socket: TCustomWinSocket);
procedure Button4Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Nickname:
String;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Server.Active := True;
Label1.Font.Color := clgreen;
Label1.Caption := '
Server gestartet';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Server.Close;
Server.Active := False;
Label1.Font.Color := clred;
Label1.Caption := '
Server nicht gestartet';
end;
procedure TForm1.ServerClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var I: Integer;
test:
String;
begin
test := Socket.ReceiveText;
For I := 0
to Server.Socket.ActiveConnections - 1
do
begin with Server.Socket.Connections [I]
do
if (Connected)
then SendText(test);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Client.Host := Edit2.Text;
Client.Active := True;
Nickname := Edit1.Text;
Label4.Caption := '
Verbunden mit : ' + Client.Host;
Label4.Font.Color := clgreen;
Delay(500);
Client.Socket.SendText(Nickname + '
hat sich angemeldet.')
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Client.Active := False;
Label4.Caption := '
Nicht Verbunden';
Label4.Font.Color := clred;
end;
procedure TForm1.delay(time:word);
var Start: Integer;
begin
Start:=GetTickCount;
while (GetTickCount)-(Start) <= time
do
Application.ProcessMessages;
end;
procedure TForm1.ClientRead(Sender: TObject; Socket: TCustomWinSocket);
begin
Memo1.Lines.Add(Socket.ReceiveText); [b]<<< Hier stoppt es[/b]
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Client.Socket.SendText(Edit3.Text);
end;
end.