Article View: borland.public.cppbuilder.internet.socket
Article #1925@RLebau - Modification of IdTCPConnection breaks existing apps
From: Frank Gruber
Date: Sun, 08 Oct 2006 19:41
Date: Sun, 08 Oct 2006 19:41
45 lines
2667 bytes
2667 bytes
Hi Remy,
the last modification you made in IdTCPConnection::ReadStream breaks
existing code of my application. I'm not sure if it is intended by the
new design or is simply a bug. Maybe you could take a look at.
// RLebeau - don't call Connected() here! ReadBuffer() already
// does that internally. Calling Connected() here can cause an
// EIdConnClosedGracefully exception that breaks the loop
// prematurely and thus leave unread bytes in the InputBuffer.
// Let the loop catch the exception before exiting...
while {Connected and} (LWorkCount > 0) do begin
i := Min(LWorkCount, LBufSize);
//TODO: Improve this - dont like the use of the exception handler
//DONE -oAPR: Dont use a string, use a memory buffer or better yet
the buffer itself.
try
try
ReadBuffer(LBuf[0], i);
except
on E: Exception do begin
// RLebeau - ReadFromStack() inside of ReadBuffer()
// could have filled the InputBuffer with more bytes
// than actually requested, so don't extract too
// many bytes here...
i := Min(i, InputBuffer.Size);
Move(InputBuffer.Memory^, LBuf[0], i);
InputBuffer.Remove(i);
if not (E is EIdConnClosedGracefully) or not
AReadUntilDisconnect then begin
raise;
end;
end;
--------
My app (TIdHTTP) allways gets into an infinite loop at the code shown.
When running with the debugger an EIdConnClosedGracefully exception is
thrown endless but the loop is never left. The server is a TIdHTTPServer
descendant. Any ideas how to fix this? The previous version of
IdTCPConnection does not show this problem.
Thanks.
Regards,
Frank.
Technical Details
Message-ID:
<4529537f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5ec53a2bfef052d5,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Sun, 08 Oct 2006 21:41:50 +0200 From: Frank Gruber <HVFDMIPUMFPS@spammotel.com> User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.socket Subject: @RLebau - Modification of IdTCPConnection breaks existing apps Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 88.19.24.239 Message-ID: <4529537f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1160336255 88.19.24.239 (8 Oct 2006 12:37:35 -0700) Lines: 45 Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail