🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
8 messages
8 total messages Started by Dennis Jones Thu, 25 Jan 2007 20:38
TIdTCPClient connect timeout problem
#1462
Author: Dennis Jones
Date: Thu, 25 Jan 2007 20:38
10 lines
1426 bytes
I am trying to establish a connection using the TIdTCPClient component. 
When I call Connect(), I pass a timeout value (such as 5000), but the 
timeout value seems to have no effect.  When the connection cannot be made, 
the Connect call throws an exception in about 1 second (which I presume is 
the default), regardless of the timeout value I use.  What am I doing wrong?

Aside: The default timeout value specified in the Connect method is 
0xFFFFFFFF (-1).  Is that supposed to mean "inifinite" or "no timeout?"

- Dennis 
Re: TIdTCPClient connect timeout problem
#1461
Author: Remy Lebeau (TeamB)
Date: Thu, 25 Jan 2007 20:57
30 lines
1771 bytes
"Dennis Jones" <nospam@nospam.com> wrote in message
news:45b91533$1@newsgroups.borland.com...

> When I call Connect(), I pass a timeout value (such as 5000), but
> the timeout value seems to have no effect.

Yes, it does.

> When the connection cannot be made, the Connect call throws an
> exception in about 1 second

That is perfectly normal.  The Timeout is the maximum amount of time
that Connect() will wait.  If the timeout elapses, Connect() will
throw an EIdConnectTimeout exception.  If the OS reports an error
before the timeout elapses, Connect() will throw an EIdSocketError or
EIdConnectException exception sooner.

> What am I doing wrong?

Nothing at all.

> The default timeout value specified in the Connect method is
> 0xFFFFFFFF (-1).  Is that supposed to mean "inifinite" or "no
timeout?"

Yes.


Gambit
Re: TIdTCPClient connect timeout problem
#1463
Author: Dennis Jones
Date: Thu, 25 Jan 2007 21:02
16 lines
1310 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:45b91996$1@newsgroups.borland.com...
>
>> The default timeout value specified in the Connect method is
>> 0xFFFFFFFF (-1).  Is that supposed to mean "inifinite" or "no
> timeout?"
>
> Yes.

Which one?

"no timeout" = return immediately if connection not established
"infinite" = wait indefinitely

- Dennis 
Re: TIdTCPClient connect timeout problem
#1460
Author: Dennis Jones
Date: Thu, 25 Jan 2007 21:08
20 lines
1915 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:45b91996$1@newsgroups.borland.com...
>
> That is perfectly normal.  The Timeout is the maximum amount of time
> that Connect() will wait.  If the timeout elapses, Connect() will
> throw an EIdConnectTimeout exception.  If the OS reports an error
> before the timeout elapses, Connect() will throw an EIdSocketError or
> EIdConnectException exception sooner.

Ah, thank you...so "Socket Error 10061" (connection refused) is an OS error 
that Indy doesn't take into consideration.

OK, then is there a way to say, "Keep trying to connect and don't give up 
for at least X ms?"  I'd prefer to have it keep trying for some period of 
time so that if the server should happen to come up during that timeout 
period, the connection will be established automatically.  Or must I 
manually poll the server until my desired timeout expires?

- Dennis 
Re: TIdTCPClient connect timeout problem
#1464
Author: Bob Gonder
Date: Thu, 25 Jan 2007 21:28
14 lines
1362 bytes
Dennis Jones wrote:

>Which one?

Both.

>"no timeout" = return immediately if connection not established

No.
No timeout means there is no timeout. It never times out, the timeout
is effectively infinite.

You are probably confusing No timeout with Zero timeout, which is
completely different.
Re: TIdTCPClient connect timeout problem
#1465
Author: Dennis Jones
Date: Thu, 25 Jan 2007 21:46
21 lines
1525 bytes
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message 
news:b38ir2l6vgccq47eh9q998acip5cc72i4k@4ax.com...
> Dennis Jones wrote:
>
>>Which one?
>
> Both.
>
>>"no timeout" = return immediately if connection not established
>
> No.
> No timeout means there is no timeout. It never times out, the timeout
> is effectively infinite.
>
> You are probably confusing No timeout with Zero timeout, which is
> completely different.

Thanks, yes...I guess I was confusing the two.

- Dennis 
Re: TIdTCPClient connect timeout problem
#1466
Author: Remy Lebeau (TeamB)
Date: Thu, 25 Jan 2007 21:52
16 lines
1388 bytes
"Dennis Jones" <nospam@nospam.com> wrote in message
news:45b91acd$1@newsgroups.borland.com...

> Which one?

Both.  "no timeout" = "infinite".

> "no timeout" = return immediately if connection not established

That is not what "no timeout" means.  If you really want it to return
immediately (which is almost impossible anyway), then just specify a
small timeout.


Gambit
Re: TIdTCPClient connect timeout problem
#1467
Author: Remy Lebeau (TeamB)
Date: Thu, 25 Jan 2007 21:54
31 lines
1821 bytes
"Dennis Jones" <nospam@nospam.com> wrote in message
news:45b91c16$1@newsgroups.borland.com...

> Ah, thank you...so "Socket Error 10061" (connection refused) is an
OS error

Yes.  An "Socket Error" is an error code that the OS reported for a
given operation.

> that Indy doesn't take into consideration.

Yes, it does.  It just ignores it, because it doesn't need to do
anything with it.

> is there a way to say, "Keep trying to connect and don't give up
> for at least X ms?"

You have to implement that in your own code, such as by calling
Connect() in a loop until the desired duration elapses.

> I'd prefer to have it keep trying for some period of time

There is nothing in Indy for that.

> Or must I manually poll the server until my desired timeout expires?

Yes.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads