Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: TIdTCPClient.Connect(Timeout not working)
| Subject: | Re: TIdTCPClient.Connect(Timeout not working) |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Mon, 3 Dec 2007 12:48:50 |
"Jamie Dale" <jamie.dale@yahoo.com> wrote in message
news:47534511@newsgroups.borland.com...
> Indy v9...
>
> TIdTCPClient.Connect's timeout doesn't seem to work!
Works fine for me.
> Why 'Terminate' here?
For exactly the reason the comment says. TIdIOHandlerSocket.ConnectClient()
checks the thread's Terminated property to know whether the OS aborted the
call to connect() earlier than the timeout elapsed, or whether the timeout
was reached.
> It seems that for some reason, the connect thread is terminated
> prematurely which nulls any connection timeout.
That is perfectly valid and common. The OS can exit from connect() as soon
as it knows a connection is either successful or failed. It does not have
to wait for the full timeout to elasped first. In fact, there is no timeout
feature available for blocking sockets to begin with. That is why Indy has
to use a manual loop instead. The timeout is the maximum amount of time
that Indy will wait. If the OS aborts earlier than the timeout, so be it.
Otherwise, Indy will close the socket manually if it was not connected (the
thread is still running when the loop is finished).
> Why is the timeout there included if it is cancelled?
It is not cancelled.
> Or am I misunderstanding it's purpose?
Apparently so.
Gambit
none