Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Aug : Re: Read data with TIdTCPClient
| Subject: | Re: Read data with TIdTCPClient |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Tue, 22 Aug 2006 10:54:05 |
"Grant Brown" <grant@sitedoc.com.au> wrote in message
news:44ea40e5@newsgroups.borland.com...
> Could you explain the "= 204" part a bit further.
You are sending a command and then waiting for 1 of 2 different reply codes
to come back. SendCmd() can return which reply code was actually sent. In
your earlier code, you are only keeping the data for the 204 reply, so I
changed your loop code to reflect that clearer. Although both replies are
still looked for, only the 204 data is actually kept, and the 203 data is
discarded.
> if SendCmd(CmdStr_NewLic, [203, 204]) = 204 then
>
> In your response the loop exits when the sendCmd() returns 204
So did your earlier code.
> but what happens when it returns 203
It will keep looping, just like your earlier code did. I'm just not calling
ReadBytes() for the 203 data anymore, since your earlier code was throwing
that data away.
> In the above send command code the 203 and 204 equate to
>
> 203 = more records to come.
> 204 = this is the last record.
You did not say that earlier, and you were not using the 203 data for
anything. If the 203 data has to actually be used, then the code I gave you
becomes the following:
with IdTCPClient do
try
repeat
SetLength(ByteBuf, 0);
SendCmd(CmdStr_NewLic, [203, 204]);
IOHandler.ReadBytes(ByteBuf, SizeOf(NewLicRec));
BytesToRaw(ByteBuf, NewLicRec, SizeOf(NewLicRec));
// use the license as needed ...
until LastCmdResult.NumericCode = 204;
except
on E: Exception do ShowMessage(E.Message);
end;
Gambit
none