Hi,

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 )
   public
     Buffer      : String;
     ConnectTime : TDateTime;
   end;

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

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

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



 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,
Clément

-- 
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