Kevin Koch wrote: > Windows experts: how can my RPC server learn that a client has gone away? > The server needs to know because it may have state that needs to be cleaned > up. >
Create a timestamp variable associated with the client structure with which you are holding state. Every time the client sends a packet, update the timestamp. Create a cleaning thread that at scheduled intervals reviews the list of client state structures and removes any whose timestamp is older than X seconds ago. None of this is specific to Windows. For Windows, if you are using I/O Completion Ports the GetQueuedCompletionStatus() call in the worker thread will complete if the remote system closes the connection. Exact details may differ between UDP and TCP but it will cause the worker thread to continue and you then you need to examine the various statuses for details. Danny > > > A) One method is for a server thread to send an RPC message to the client, > which the client never finishes processing. The server thread will get an > RPC exception when the client dies. > > > > B) Another method is for the server to hold the state until it has a reason > to talk to the client. Then it can notice that the client is not reachable. > > > > Is there any other way that has the benefits of method A (immediate > discovery, less resource consumption) without an outstanding RPC call for > each client? > > > > The server must be able to handle requests from all clients while > simultaneously detecting any client exiting. > > > > I only care about local RPC connections, if it makes any difference. > > > > I have not been able to find anything in MSDN that looks like it will work. > > > > Thanks. > > > > Kevin Koch > > _______________________________________________ > kfwdev mailing list > kfwdev@mit.edu > http://mailman.mit.edu/mailman/listinfo/kfwdev > > _______________________________________________ kfwdev mailing list kfwdev@mit.edu http://mailman.mit.edu/mailman/listinfo/kfwdev