How disconnect TidTcpClient from TIdTcpServer properly?
i mean if i call Disconnect on client side i receive 10054 connection reset by peer
on server onexception event.
if i call disconnect on AContext (using queue / OnExecute event) server return connection closed gracefully
on onexception event.
My currently protocol don't use OnConnect and OnDisconnect events, only OnExecute with a IdTCPServer1.ContextClass := TClientContext;
I mean it because when i return number of connected clients using Contexts list always return a wrong number, so now i use:
InterlockedIncrement(FClientCount);
TThread.Synchronize(nil, UpdateUI);
Increase on OnConnect event and decrease on OnDisconnect event. Since on OnException call OnDisconnect, decrease number too.
Maybe if TIdTcpClient disconnect correctly count will work perfect using Contexts List no?