I'm working on a project (Delphi 7, and ICS V5).
I built a server using TWSocketThrdServer and the clients are derived 
from TWSocketThrdClient.
Here is the code:

   TTaskClientTCP = Class( TWSocketThrdClient )
     Buffer      : String;
     ConnectTime : TDateTime;

procedure TTaskServerTCP.Internal_ClientCreated(Sender: TObject;
  Client: TWSocketClient);
     Client.OnDataAvailable := InternalEvent_ClientDataReceived;

procedure TTaskServerTCP.Internal_ClientConnected(Sender: TObject;
  Client: TWSocketClient; ErrCode : Word);
    TTaskClientTCP(Client).ConnectTime := now;

procedure TTaskServerTCP.InternalEvent_ClientDataReceived(Sender: TObject;
  ErrCode: Word);
    if ErrCode = 0 then begin
       TTaskClientTCP( Sender ).Buffer := TTaskClientTCP( Sender 
       Internal_ProcessClientData(TTaskClientTCP( Sender ) );

 two situations might happen:

1) Administrator must shutdown the server. During this shutdown I would 
like to send a msg to all clients and disconnect them "gracefully".

2) A specific client software that is used by a single "power user" can 
request a server "restart". I would like to send a command to all the 
clients that a restart has been requested. The restart should disconnect 
all clients, wait a few seconds, and reconnect again.

In my current implementation, this is still not implemented. If the 
server shuts down with live clients, bad things happens to the client 
side. The only option, is to disconnect all the clients (one by one), 
then disconnect the server. If the latter is done, the application can 
be used without any problems.

What would be the safer way to implement this shutdown? Should the 
server call a DisconnectAll, or should the server send a message to the 
client, and wait till all the clients are offline.
Is there any sample of such procedure?

Best regards,

To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to