Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIdTelnet
#4
(08-24-2022, 12:15 PM)omarreis Wrote: What I did was call IdTelnet.Disconnect from IdTelnet.TelnetThread.OnException.
This calls IdTelnet.OnDisconnected event in the case of abnormal socket disconnect,
so the application can respond to all kinds of disconnections (graceful or otherwise)

The only thing to watch out for is the TelnetThread is not created in a suspended state, so there is a very small window of opportunity where the thread could crash before you have have a chance to assign the OnException handler to it.

(08-24-2022, 12:15 PM)omarreis Wrote: I also added a form variable fIsTelnetConnected that is updated on IdTelnet events
OnConnected and OnDisconneted,  since IdTelnet.IOHandler.Connected can
return a false positive, as in the case of abnormal disconnect.

That is a good idea, since you shouldn't be using the Connected() method anyway, especially across thread boundaries. Internally it performs a read on the socket, and that can corrupt communications if the thread also reads at the same time.

Reply


Messages In This Thread
TIdTelnet - by omarreis - 08-23-2022, 11:32 AM
RE: TIdTelnet - by rlebeau - 08-23-2022, 04:29 PM
RE: TIdTelnet - by omarreis - 08-24-2022, 12:15 PM
RE: TIdTelnet - by rlebeau - 08-25-2022, 05:48 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)