I try to receive text in a idtcpclient but it does not work. This is the code that I use in a timer:
procedure TForm1.Timer2Timer(Sender: TObject);
var
receivedtext:string;
begin
if idtcpclient1.Connected = true then
begin
with idtcpclient1 do
begin
if not IOHandler.InputBufferIsEmpty then
begin
try
receivedtext := IOHandler.ReadLn;
finally
if receivedtext = '' = false then
begin
showmessage(receivedtext);
idtcpclient1.IOHandler.InputBuffer.Clear;
receivedtext := '';
end;
end;
end;
end;
end
else
begin
timer2.Enabled := false;
end;
end;
The interval of the timer is 8 ms.
The timer is automatically enabled on connect.
But I don't get an messagebox or an error when I send something.
I am sure that I written the data because when I use tclientsocket
I do receive it.
What I am doing wrong?
receivedtext = '' = false
even compile? (Show your real code please) – mjn