configuring RMI host so that it should know which client port is accessing it

末鹿安然 提交于 2019-11-28 14:28:29
Ravindra babu

You can solve the problem in multiple ways.

1) You can add one method like registerClient(String clientId, Object clientInfo) in remote interface. You can pass other relevant information in additional parameters of this method. RMI server can simple put this info in data structure like ConcurrentHashMap.

2) After invoking registerClient, you can invoke other remote methods in RMI server by passing clientId as one of the parameters in Remote methods like cube(String clientId, int num);

3) If you just need only client IP, Java already provides getClientHost() API in RemoteServer which provides the information you are looking for.

user207421

configuring RMI host so that it should know which client port is accessing it

  1. There is no 'configuration' of the RMI host that will deliver that information.

  2. The client port information is completely and utterly useless.

    • It isn't unique per client.
    • It isn't fixed per client.
    • It can and will change over the life of the client.

It sounds like a case for the Remote Session Pattern to me.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!