Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Nov : TIdTCPServer and disconnecting clients

www.cryer.info
Managed Newsgroup Archive

TIdTCPServer and disconnecting clients

Subject:TIdTCPServer and disconnecting clients
Posted by:"Michael Fritz" (spam_athome@yahoo.de)
Date:Fri, 3 Nov 2006 13:59:04

Hi,

I'm using a slightly modified coding from TIdTCPServer.TerminateAllThreads.

While disconnecting the clients works of course I would like to inform the
client why this has happened.

The main logic is here (simply copied from IdTCPServer):

LThreads := FIPServer.Threads.LockList;
try
for i := 0 to LThreads.Count - 1 do
begin
   with TIdPeerThread(LThreads[i]) do
   begin
     Connection.DisconnectSocket;
     Memo.Lines.Add(Format('Disconnected client thread with ID %d at IP
%s',[ThreadID, 'XXXX']));
  end;
end;
finally
   FIPServer.Threads.UnlockList;
end;

Now I've got two (perhaps simple) problems. First, how do I get the clients
IP I've currently closed and second, how can I inform the clients with e.g.
a simple message why the server closed the connection.

What coding is needed server and/or client side? At least the event
OnDisconnected on my clients won't be called when the server disconnects.

--
cu,
Michael

Replies:

www.cryer.info
Managed Newsgroup Archive