 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Michael Zeringue Guest
|
Posted: Thu Jan 27, 2005 10:36 pm Post subject: TIdTCPConnection.WaitFor bug |
|
|
In the Indy 9 source for TIdTCPConnection.WaitFor there is a todo comment:
//TODO: Bug - returns too much data. Should only return up to search
string adn not including
// and leave the rest in the buffer.
Has this bug been fixed? I've looked at what I believe to be the latest
dev snapshot from the VCS as suggested on indyproject.org (since this is
my first pull down of this I may have down this wrong) and the comment
is still there.
If not, I have a proposed solution:
function TIdTCPConnection.WaitFor(const AString: string): string;
//TODO: Add a time out (default to infinite) and event to pass data
//TODO: Add a max size argument as well.
//TODO: Add a case insensitive option
var
LStringPos : integer;
begin
Result := '';
// NOTE: AnsiPos should be used here, but AnsiPos has problems if
result has any #0 in it,
// which is often the case. So currently this function is not MBCS
compliant and should
// not be used in MBCS environments. However this function should
only be used on incoming
// TCP text data as it is 7 bit.
LStringPos := MemoryPos(AString, PCHAR(InputBuffer.Memory),
InputBuffer.size);
while LStringPos = 0 do begin
Result := Result + InputBuffer.Extract(InputBuffer.size);
CheckForDisconnect;
ReadFromStack;
LStringPos := MemoryPos(AString, PCHAR(InputBuffer.Memory),
InputBuffer.size);
end;
Result := Result + InputBuffer.Extract(LStringPos + length(AString) - 1);
end;
I have not spent much time studying the source of Indy, but I modelled
this after other functions I found browsing looking for the source of my
error (too much data).
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Jan 27, 2005 10:58 pm Post subject: Re: TIdTCPConnection.WaitFor bug |
|
|
"Michael Zeringue" <michael (AT) no (DOT) smap.zclient.com> wrote
| Quote: | In the Indy 9 source for TIdTCPConnection.WaitFor there is a todo comment:
|
This has been fixed in Indy 10.
| Quote: | Has this bug been fixed?
|
Not for Indy 9, no.
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|