Delphi-Quellcode:
procedure TForm3.Button1Click(Sender: TObject);
begin
if TCPClient.Connected = TRUE
then begin
try
TCPClient.Disconnect;
Button1.Caption := 'Client starten';
Memo1.Lines.Add('Client beendet');
except
on E: EIdSocketError do
ShowMessage('Fehler:'#13 + E.Message);
end;
end
else begin
try
TCPClient.Connect;
Button1.Caption := 'Client beenden';
Memo1.Lines.Add('Client gestartet');
except
on E: EIdSocketError do
ShowMessage('Fehler:'#13 + E.Message);
end;
end;
end;
Delphi-Quellcode:
procedure TForm3.Button2Click(Sender: TObject);
begin
try
TCPClient.IOHandler.WriteLn(Edit1.text);
Memo1.Lines.Add(Edit1.Text + ' an Server gesendet');
Edit1.Text := '';
except
on E: EIdSocketError do
ShowMessage('Fehler:'#13 + E.Message);
end;
end;
Das ist mein Code, trotz der try...except blöcke gibt es die
exception.