Forum > Networking and Web Programming

INDY -SOLVED - How to properly disconnect client from indyTCPserver

(1/1)

Mongkey:
 
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  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:
Thank you bogen85  :)
SOLVED BY

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  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:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Procedure Tf_main.disconnectTCP();begin  IdTCPSERVER.OnDisconnect := nil;  IdTCPSERVER.Active := false;end;

Mongkey:
Thank you remi.

Navigation

[0] Message Index

Go to full version