Also ich wollte da ein bisschen üben und steh jetzt schon vor einem Fehler....
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
//initialisieren der sockets
Server := TServerSocket.Create(Form1);
Client := TClientSocket.Create(Form1);
label2.Caption := IPWatch.LocalIP;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Client.Active = true then
begin
Client.Socket.SendText(edit1.Text);
delay(500);
edit1.clear;
end;
end;
procedure TForm1.ServerClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var msg: string;
begin
Memo1.Lines.Add(Socket.ReceiveText);
end;
procedure TForm1.delay(time:word);
var start: integer;
begin
start := GetTickCount;
while (GetTickCount) - (start) <= time do
Application.ProcessMessages;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Server.Free;
Client.Free;
end;
procedure TForm1.ClientConnect(Sender: TObject; Socket: TCustomWinSocket);
begin
Memo1.Lines.Add('**connected')
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//Port zuweisein
Server.Port := 44044;
Client.Port := 44044;
//listening status on / connecten
try
Client.Host := IPWatch.LocalIP;
Server.Open;
Client.Open;
except
Application.MessageBox('Verbinden fehlgeschlagen','Fehler',0+48);
Server.Free;
Client.Free;
close;
end;
end;
procedure TForm1.ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo1.Lines.Add('**Disconected');
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Server.Close;
Client.Close;
end;
end.
Findet da jmd einen Fehler?
mfG Matrix Scripter