Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Apr : Re: Handle disconnection in TIdCmdTCPClient

www.cryer.info
Managed Newsgroup Archive

Re: Handle disconnection in TIdCmdTCPClient

Subject:Re: Handle disconnection in TIdCmdTCPClient
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Mon, 23 Apr 2007 11:58:49

"David" <focusme@yeah.net> wrote in message
news:462c75a4@newsgroups.borland.com...

> When use TidCmdTCPClient to connect to a server, after connected,
> but the line lost (for example, the switch is power off), how to
know
> it in TIdCmdTCPClient?

You don't.

> the program will raise an exception after the line lost (I guess it
is
> because of the Listen Thread in TIdCmdTCPClient).

The exception is raised in the context of the listening thread, yes.
Since it is private to TIdCmdTCPClient's internals, you don't have any
access to the exception, or even to know when the thread is terminated
because of it.

> But in single run mode, it seems don't know the line is lost, or
raise
> a "Connection reset by peer" error box, how to hide this box?

The box only appears during debugging, regardless of how your are
running the code.  The debugger is displaying a raised exception.
There is no such box displayed when running outside of the debugger.

> I need to handle it in my own program.

Then you are out of luck, as there is no event available right now for
handling exceptions on the connection.  Unless you write to the
connection periodically and catch the disconnect exception from that.


Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive