Procedure ReadClientLines();
var
linea : string;
Begin
if not ClientChannel.Connected then Exit;
try
if ClientChannel.IOHandler.InputBufferIsEmpty then
begin
ClientChannel.IOHandler.CheckForDataOnSource(10);
if ClientChannel.IOHandler.InputBufferIsEmpty then Exit;
end;
repeat
// consider setting the IOHandler.DefStringEncoding beforehand, such as
// at connection open. No need to pass it in to ReadLn() every time...
//
// ClientChannel.ReadTimeout := ReadTimeOutTime;
Linea := ClientChannel.IOHandler.ReadLn('', ReadTimeOutTime, -1, IndyTextEncoding_UTF8);
if ClientChannel.IOHandler.ReadLnTimedOut then Exit;
// use Linea as needed...
until ClientChannel.IOHandler.InputBufferIsEmpty;
except
on E: Exception do
ReportTheError(E.Message);
end;
end;