Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIdTelnet
#2
(08-23-2022, 11:32 AM)omarreis Wrote: Works fine for iOS and Android

It should be working the same way on all platforms.

(08-23-2022, 11:32 AM)omarreis Wrote: but on Windows I cannot detect when the client was disconnected by the server.  If I try to send data on the closed socket I get 10054 error.

I tried OnDisconnect and OnStatus events, but it seems that those are not called when the socket is closed by the server.

The OnDisconnect is fired only when your app calls Disconnect() on the client.

If the server closes the connection gracefully (sends a FIN), then you should be getting an OnStatus(hsDisconnected) event fired after the FIN is received.

If the connection is lost abnormally, you are not going to get any event fired for that. The IOHandler will just raise exceptions instead on any failed socket operations. Which, in the case of reading incoming data, that exception will just be swallowed by the internal thread that TIdTelnet creates for itself. In which case, you might try assigning an OnException event handler to the TIdTelnet.TelnetThread property after TIdTelnet.Connect() exits successfully.

I'll look into adding some additional internal handling to get an event fired on unexpected disconnects. Oh, wait... there is already an open ticket for that:

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

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)