06-17-2020, 05:58 PM
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
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;