INDY -SOLVED - How to properly disconnect client from indyTCPserver lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Mongkey · 2023-02-16 11:20 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   begin   for counter := 0 to ServerClientsCount-1 do      if IdTCPServer1.Contexts[counter] doNotExistsInMyConnections then         IdTCPServer1.Contexts[counter].Connection.Disconnect;   end; I could not found this syntax "IdTCPServer1.Contexts[counter] " on lazarus indy? Thank you. ---------------------------------------------------------------------- Mongkey · 2023-02-16 13:59 Thank you bogen85  SOLVED BY Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Procedure Tf_main.disconnectTCP();varList: TIdContextList;  Context: TIdContext;begin  IdTCPSERVER.OnDisconnect  := nil;  List := IdTCPSERVER.Contexts.LockList;  //rmemo_listen.Lines.Add('list:' + IntToStr(List.Count));  try    for I := 0 to List.Count - 1 do    begin      Context := TIdContext(List[I]);      Context.Connection.Disconnect;    end;  finally    IdTCPSERVER.Contexts.UnlockList  end;IdTCPSERVER.active := false;end; ---------------------------------------------------------------------- Remy Lebeau · 2023-02-17 22:46 You DO NOT need to disconnect active clients manually before deactivating the server.  The TIdTCPServer.Active property setter will handle that internally for you.  So, just deactivate the server normally, let Indy do the rest. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure Tf_main.disconnectTCP();begin  IdTCPSERVER.OnDisconnect := nil;  IdTCPSERVER.Active := false;end; ---------------------------------------------------------------------- Mongkey · 2023-02-18 02:10 Thank you remi.