|Subject:||Re: Correct way to read records in Indy 10 with TIdTCPClient|
|Posted by:||Remy Lebeau (Indy Team) (firstname.lastname@example.org)|
|Date:||Mon, 21 Aug 2006|
"Grant Brown" <gra…@sitedoc.com.au> wrote in message
> Is the following the correct manner in which to read records
> using the TIdTCPClient component in Indy 10.
No. You are calling ReadBytes(), which fills a TIdBytes. But you are
specifying SizeOf(ByteBuf) where you need to use SizeOf(NewLicRec)) instead.
You can't call SizeOf() on a TIdBytes, it will alyways report the wrong
> Also how would I gard against a lost connection during the repeat loop
The reading will throw an exception that you are not catching yet, so the
loop will automatically exit when the connection is lost.
Try this code instead:
with IdTCPClient do
if SendCmd(CmdStr_NewLic, [203, 204]) = 204 then
BytesToRaw(ByteBuf, NewLicRec, SizeOf(NewLicRec));
end else begin
on E: Exception do ShowMessage(E.Message);
Correct way to read records in Indy 10 with TIdTCPClient posted by Grant Brown on Mon, 21 Aug 2006