🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
2 messages
2 total messages Started by Colin B Maharaj Sun, 31 Dec 2006 11:11
TCPClient Connect Question
#1562
Author: Colin B Maharaj
Date: Sun, 31 Dec 2006 11:11
29 lines
1884 bytes
Hi all, firstly thanks again to all that has assisted me this
year it has been good. And for those who are down and out
I really wish you a great day today and that things
get better and better in the following year (honestly)!

Anyway I have a thread that is doing some Indy stuff.
First it connects then does what it has to do until
I terminate the thread.

Thing is I am doing testing with an invalid I.P. address
and want the connection to fail (no problem) also
the Connect() command may take a few seconds (5 to 10)
before it fails.

But within say 1-2 seconds I may change my mind and want
to close the thread, but this is in te middle of the Connect
method.

So the problem is how do I 'intercept' the Connect() method
while it is trying hard to connect to an invalid address
so that I can quickly exit my thread.
e.g. force time out the Connect method.

Thanks again!!!
And have a great new year!!


Colin B Maharaj
Trinidad, W.I.
Re: TCPClient Connect Question
#1564
Author: Remy Lebeau (TeamB)
Date: Sun, 31 Dec 2006 21:29
22 lines
1618 bytes
"Colin B Maharaj" <noreply@myhost.com> wrote in message
news:45979aa9$1@newsgroups.borland.com...

> Thing is I am doing testing with an invalid I.P. address
> and want the connection to fail (no problem) also the Connect()
> command may take a few seconds (5 to 10) before it fails.

That is normal for TCP.  It can take awhile for a host to be detected
as invalid if it canot be reached right away.

> But within say 1-2 seconds I may change my mind and want
> to close the thread, but this is in te middle of the Connect
> method.

You can disconnect the socket from within a different thread (such as
the thread that wants to terminate the worker thread), which will
cause Connect() to fail immediately within the worker thread that
called it.


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