Board index » delphi » Indy TIdSMTP timeout

Indy TIdSMTP timeout


2008-07-17 06:59:11 AM
delphi141
Delphi 5.
In the TIdSMTP.Connect method, in order to set the timeout to infinity, do I
use 0?
eg.
IdSMTP.Connect(0)
or
IdSMTP.Connect()?
However, looking into the source code of TIdSMTP.Connect, it does not use
this timeout parameter:
procedure TIdSMTP.Connect(const ATimeout: Integer = IdTimeoutDefault);
var
NameToSend : String;
begin
inherited;
try
GetResponse([220]);
FAuthSchemesSupported.Clear;
if Length(FHeloName)>0 then
NameToSend := FHeloName
else
NameToSend := LocalName;
if FUseEhlo and (SendCmd('EHLO ' + NameToSend )=250) then begin //APR:
user can prevent EHLO {Do not Localize}
GetAuthTypes;
end
else begin
SendCmd( 'HELO ' + NameToSend, 250 ); {Do not Localize}
end;
except
Disconnect;
Raise;
end;
end;
 
 

Re:Indy TIdSMTP timeout

"Man T" <XXXX@XXXXX.COM>writes
Quote
However, looking into the source code of TIdSMTP.Connect, it does not use
this timeout parameter:

inherited;
I'm reckoning it might be something to do with the above...
 

Re:Indy TIdSMTP timeout

"Man T" <XXXX@XXXXX.COM>writes
Quote
"Jamie Dale" <XXXX@XXXXX.COM>writes
>>inherited;
>
>I'm reckoning it might be something to do with the above...

So do I use 0 or leave the parameter blank to set the timeout as infinity?
ie
IdSMTP.Connect(0)
or
IdSMTP.Connect()?
I'm reckoning you would use a 0 - as in 0 for no timeout. I couldn't promise
though as its just a guess. I am not that knowledgable with how indys
internals work - I just noticed the inherited bit which would explain what
you were looking for.
I'm sure Remy will be able to give you a better idea.
 

Re:Indy TIdSMTP timeout

Further thoughts...
I'm sure Remy said a while back in another topic that the OS itself will
time out if a socket doesn't connect.
I think Indys timeout is just a timeout if the server doesn't acknowledge
the connection in a reasonable time - I think if the OS itself accepts the
connection the timeout doesn't work - Only if the server doesn't respond...
I'm probably wrong but thats a vague memory...
"Jamie Dale" <XXXX@XXXXX.COM>writes
Quote

"Man T" <XXXX@XXXXX.COM>writes
news:487e97f5$XXXX@XXXXX.COM...
>"Jamie Dale" <XXXX@XXXXX.COM>writes

>>>inherited;
>>
>>I'm reckoning it might be something to do with the above...
>
>So do I use 0 or leave the parameter blank to set the timeout as
>infinity?
>ie
>IdSMTP.Connect(0)
>or
>IdSMTP.Connect()?

I'm reckoning you would use a 0 - as in 0 for no timeout. I couldn't
promise though as its just a guess. I am not that knowledgable with how
indys internals work - I just noticed the inherited bit which would
explain what you were looking for.

I'm sure Remy will be able to give you a better idea.

 

Re:Indy TIdSMTP timeout

"Man T" <XXXX@XXXXX.COM>writes
Quote
Delphi 5.
In the TIdSMTP.Connect method, in order to set the timeout
to infinity, do I use 0?
To explicitally use an infinite timeout, use IdTimeoutInfinite instead:
IdSMTP.Connect(IdTimeoutInfinite)
Specifying 0 is the same as specifying IdTimeoutDefault (which is what
Connect() defaults to). That causes Connect() is wait a maximum of 2
minutes when TIdAntiFreeze is used, or until the socket errors on its own.
Quote
However, looking into the source code of TIdSMTP.Connect,
it does not use this timeout parameter:
TIdSMTP.Connect() does not use it. It is passed on to
TIdTCPClient.Connect(), which then passes it on to
TIdIOHandlerSocket.ConnectClient(), where it is actually used.
Gambit
 

Re:Indy TIdSMTP timeout

"Jamie Dale" <XXXX@XXXXX.COM>writes
Quote
I'm sure Remy said a while back in another topic that
the OS itself will time out if a socket doesn't connect.
If it takes longer than the specified timeout, yes.
Quote
I think Indys timeout is just a timeout if the server doesn't
acknowledge the connection in a reasonable time
Indy's timeout is used to force a disconnect if the socket takes too long to
connect without erroring.
Quote
I think if the OS itself accepts the connection the timeout
doesn't work
If the socket is connected successfully, the remainder of the timeout is
ignored. Any activity on the connection is subject to the ReadTimeout
property from that point on.
Gambit