Article View: borland.public.cppbuilder.internet.socket
Article #2424Re: ConnectTimeout + Indy9 -> Slowdown?
From: Frank Gruber
Date: Fri, 28 Apr 2006 20:07
Date: Fri, 28 Apr 2006 20:07
82 lines
3731 bytes
3731 bytes
Remy Lebeau (TeamB) schrieb:
> "Mark Jacobs" <http://www.jacobsm.com/mjmsg?Borland%20Newsgroup> wrote in
> message news:4451e679@newsgroups.borland.com...
>
>> I am afraid that is bad programming on the part of the Indy team.
>
> What would you suggest as an alternative?
The following is what I changed to meet my requirements. However there
may be others saying it is bad programming also.
procedure TIdIOHandlerSocket.ConnectClient(const AHost: string;
const APort: Integer; const ABoundIP: string; const ABoundPort,
ABoundPortMin, ABoundPortMax: Integer; const ATimeout: Integer =
IdTimeoutDefault);
procedure ConnectTimeout(ATimeout: Integer);
const
LSleepTimes: array[0..8] of Integer = (1, 2, 5, 10, 20, 20, 50,
100, 125);
var
LSleepTime: Integer;
LInfinite: Boolean;
LSleepIndex: Integer;
begin
LInfinite := ATimeout = IdTimeoutInfinite;
LSleepIndex := 0;
with TIdConnectThread.Create(True) do try
FBinding := Binding;
Resume;
// Sleep
if TIdAntiFreezeBase.ShouldUse then begin
LSleepTime := Min(GAntiFreeze.IdleTimeOut, 125);
end else begin
LSleepTime := LSleepTimes[LSleepIndex];
end;
if LInfinite then begin
ATimeout := LSleepTime + 1;
end;
while ATimeout > LSleepTime do begin
IdGlobal.Sleep(LSleepTime);
ATimeout := ATimeout - LSleepTime;
if not TIdAntiFreezeBase.ShouldUse then begin
if (LSleepIndex < 8) then begin
LSleepIndex := LSleepIndex + 1;
LSleepTime := LSleepTimes[LSleepIndex];
end;
end;
if LInfinite then begin
ATimeout := LSleepTime + 1;
end;
TIdAntiFreezeBase.DoProcess;
if Terminated then begin
ATimeout := 0;
Break;
end;
end;
if ATimeout > 0 then
IdGlobal.Sleep(ATimeout);
//
if Terminated then begin
if Length(FExceptionMessage) > 0 then begin
if FLastSocketError <> 0 then begin
raise EIdSocketError.CreateError(FLastSocketError,
FExceptionMessage);
end else begin
raise EIdConnectException.Create(FExceptionMessage);
end;
end;
end else begin
Terminate;
Close;
WaitFor;
raise EIdConnectTimeout.Create(RSConnectTimeout);
end;
finally Free; end;
end;
Technical Details
Message-ID:
<44527506@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.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-mailReferences:
<444d23f3$1@newsgroups.borland.com> <444d4b56@newsgroups.borland.com> <444dfc73@newsgroups.borland.com> <444e503c$3@newsgroups.borland.com> <444e5b9b$1@newsgroups.borland.com> <4451e679@newsgroups.borland.com> <44524806@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,726a735ed01da85d X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Fri, 28 Apr 2006 22:07:37 +0200 From: Frank Gruber <ZJQBBYSESPEZ@spammotel.com> User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: ConnectTimeout + Indy9 -> Slowdown? References: <444d23f3$1@newsgroups.borland.com> <444d4b56@newsgroups.borland.com> <444dfc73@newsgroups.borland.com> <444e503c$3@newsgroups.borland.com> <444e5b9b$1@newsgroups.borland.com> <4451e679@newsgroups.borland.com> <44524806@newsgroups.borland.com> In-Reply-To: <44524806@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 84.190.223.148 Message-ID: <44527506@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1146254598 84.190.223.148 (28 Apr 2006 13:03:18 -0700) Lines: 83 Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.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