Board index » delphi » The connect method doesn't timeout on time

The connect method doesn't timeout on time

  I use indy 9.0.11 for Delphi 6 in windows 2000.

  In some threads I want to use idSmtp.connect(15000) to connect the EMail
Extrange server. Usually it works fine. Although sometimes it timeout longer
then FidSmtp.ReadTimeOut a little.

  But, sometimes, it doesn't timeout if cannot connect the target server. it
doesn't respect the timeout parameter (15000) nor the ReadTimeOut property.
And sometimes it will hang up for a long time.

Some code is list below:

FidSmtp:=TIdSmtp.Create(nil);
FidSmtp.ReadTimeOut:= 120000;
FidSmtp.Host:=MX; file://The EMail Extrange server is good
FidSmtp.connect(15000);
file://Sometimes the thread stops here much longer then 15000 and 120000.

if FidSmtp.connected then begin
......
end;

Could you please help me to resolve the problem for me? I very appreciate
it.

 

Re:The connect method doesn't timeout on time


Quote
softgold <softg...@163.net> wrote in message

news:3ead250b@newsgroups.borland.com...

Quote
>   I use indy 9.0.11 for Delphi 6 in windows 2000.

>   In some threads I want to use idSmtp.connect(15000) to connect
the EMail
> Extrange server. Usually it works fine. Although sometimes it
timeout longer
> then FidSmtp.ReadTimeOut a little.

This is a read timeout, not a connect timeout.

Quote
>   But, sometimes, it doesn't timeout if cannot connect the target
server. it
> doesn't respect the timeout parameter (15000) nor the ReadTimeOut
property.
> And sometimes it will hang up for a long time.

The connect timeout is calculated/defined by Winsock.  To avoid
connect waits{*word*154} your app, run the SMTP in a seperate thread.

Rgds,
Martin.

Re:The connect method doesn't timeout on time


"Martin James" <mjames_fal...@dial.pipex.com> wrote in
news:3ead4c5c@newsgroups.borland.com:

Quote
>>   In some threads I want to use idSmtp.connect(15000) to connect
> the EMail
>> Extrange server. Usually it works fine. Although sometimes it
> timeout longer
>> then FidSmtp.ReadTimeOut a little.

> This is a read timeout, not a connect timeout.

There are two timeouts, the one in connect is a connect timeout.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Got Indy? Got the book?

   http://www.atozedsoftware.com/indy/book/

ELKNews - Get your free copy at http://www.atozedsoftware.com

Re:The connect method doesn't timeout on time


While I set the connect timeout and read timeout all to 15000,
the connect waits also hangs my application.
I run the SMTP through Socks5 proxy in a seperate thread.
If not through proxy, it will be better much more.
My code lists below:

      try
        FidSmtp.IOHandler:=TidIoHandlerSocket.Create(FidSmtp);
        FidSmtp.Socket.SocksInfo:=TidSocksInfo.Create(FidSmtp.Socket);
        with FidSmtp.Socket.SocksInfo do begin
          Version:=svSocks5;
          Host:=strSocks5Host;
          Port:=intSocks5Port;
        end;
      except
      end;
     ......

      FidSmtp.ReadTimeout:=15000;
      FidSmtp.connect(15000);      // The connect hangs here for at least 5
minutes
     ......

     SendBody(FidMsg);        // Sometimes the application also hangs here
for at least 5 minutes

What can I do? Please help me, Thank you!

Quote
> This is a read timeout, not a connect timeout.
> The connect timeout is calculated/defined by Winsock.  To avoid
> connect waits{*word*154} your app, >
> Rgds,
> Martin.

Other Threads