Supply
Supply

Reputation: 51

How to catch telnet disconnection (Delphi Indy telnet)?

I'm using Indy telnet client component in Delphi program. Now i need to catch telnet disconnection (for example when some other program connect to the same host my connection broke). How to catch it?

Upvotes: 1

Views: 795

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596397

You can use the OnStatus event, checking for the hsDisconnected status.

At this time, TIdTelnet does not trigger either the OnDisconnect or OnStatus event when the connection is closed unexpectedly. This is a known issue that has an open ticket in Indy's issue tracker:

#118: TIdTelnet needs to trigger OnDisconnect or OnStatus when disconnected

Until this is fixed, you would have to modify TIdTelnet's source code to hook into its internal reading thread, or at least assign on OnTerminate handler to it, to detect when it stops running.

Upvotes: 2

Related Questions