BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TIdTCPConnection.WaitFor bug

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Michael Zeringue
Guest





PostPosted: Thu Jan 27, 2005 10:36 pm    Post subject: TIdTCPConnection.WaitFor bug Reply with quote



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





PostPosted: Thu Jan 27, 2005 10:58 pm    Post subject: Re: TIdTCPConnection.WaitFor bug Reply with quote




"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.