Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IdTcpServer Kick Client (Disconnect) INVALID HANDLE Exception
#1
Hello everybody,
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.

How to solve this issue
Code:
var
  LList: TList;
  n1: Integer;
begin
  while True do
  begin
    Sleep(1);

    LList := IdTCPServer1.Contexts.LockList;
    try
      for n1 := 0 to LList.Count-1 do
        if TIdContext(LList[n1]).IsKickedClient then
          TIdContext(LList[n1]).Connection.Disconnect;
    finally
      IdTCPServer1.Contexts.UnlockList;
      LList := nil;
    end;
  end;
end;
Reply


Messages In This Thread
IdTcpServer Kick Client (Disconnect) INVALID HANDLE Exception - by 3ddark - 06-17-2020, 05:58 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)