How can I uniquely identify clients in RMI?
First -- there is always CallBack. By passing the Server the Client "RemoteObject", the Server knows the ID of the Client.
Secondly -- Although there is an rmi Server method, getClientHost(), this method generally is unacceptable:
- The method only returns the TCP address of the host on which the client resides, not the actual client identification and this method is only available to pure Java, (not RMI-IIOP or other plug-in), implementations.
Using a physical address to identify a client is usually not a good idea. The network may change, machines come and go. This is "hard wiring". When the location changes, then an administrator must alter all tables. Using a "soft wiring" method means the client can take its identification with it when it moves.
Thirdly, the RMI Runtime keeps track of the identification of Clients that have unmarshalled this Server's RemoteObject. (This has to do with the Distributed Garbage Collector.) However, API access to this data is not available.
Therefore, we advise our customers to include a unique identifier, (possibly a long integer), for use by the Server within the parameter it passes to the Server.