Discussion:
Indy TIdSMTP timeout
(too old to reply)
Man T
2008-07-16 22:59:11 UTC
Permalink
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;
Jamie Dale
2008-07-16 23:06:30 UTC
Permalink
Post by Man T
However, looking into the source code of TIdSMTP.Connect, it does not use
inherited;
I'm reckoning it might be something to do with the above...
Man T
2008-07-17 00:54:11 UTC
Permalink
Post by Jamie Dale
Post by Man T
However, looking into the source code of TIdSMTP.Connect, it does not use
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()?
Jamie Dale
2008-07-17 14:03:10 UTC
Permalink
Post by Man T
Post by Jamie Dale
Post by Man T
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'm 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.
Jamie Dale
2008-07-17 17:15:05 UTC
Permalink
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...
Post by Jamie Dale
Post by Man T
Post by Jamie Dale
Post by Man T
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'm 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.
Remy Lebeau (TeamB)
2008-07-17 18:37:38 UTC
Permalink
Post by Jamie Dale
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.
Post by Jamie Dale
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.
Post by Jamie Dale
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

Remy Lebeau (TeamB)
2008-07-17 18:34:36 UTC
Permalink
Post by Man T
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.
Post by Man T
However, looking into the source code of TIdSMTP.Connect,
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
Loading...