Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IdTcpServer Kick Client (Disconnect) INVALID HANDLE Exception
#2
(06-17-2020, 05:58 PM)3ddark Wrote: I have a TCP Server application as ConsoleApp. Sometimes i need Disconnect to some client/s. I use like this code in main loop.
But I get an error after Disconnect  ----> INVALID HANDLE

I gues(probally) after disconnect then lost thread handle.

What does the call stack actually look like when the exception is raised? I suspect the error is due to an invalid socket handle, not a thread handle, such as if the client were already disconnected but its context hadn't been removed from the list yet. You might need to set another flag in the OnDisconnect event that your loop can then look for, so it doesn't try to disconnect clients that are already disconnect(ing|ed).

Is there a particular reason why you are kicking clients from your main thread, and not from the individual client threads? For instance, by having the main thread merely set a flag that the OnExecute event can then look for to call Disconnect().

Reply


Messages In This Thread
RE: IdTcpServer Kick Client (Disconnect) INVALID HANDLE Exception - by rlebeau - 06-17-2020, 07:39 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)