Get the number of clients connected to the RMI service

I have a service Remote

exported via RMI. Can I get the number of clients connected to this service?

I would prefer my own method (counting sockets) over creating my own solution where clients have to register, as I need this for error detection, and my own solution would be the least error prone.

Getting the exact number of clients would be nice, but mostly I'm just curious to know if 0 or not.

+3


source to share


1 answer


There is no such thing as "the number of clients connected to the RMI service" because there is no such state as "connected to the RMI service". RMI has no explicit connections. It has hidden TCP connections, but they are transient in nature.



You can count the different incoming values RemoteServer.getClientHost()

, but then you assume hosts = clients and you still don't know when the client last called you. If your application doesn't know, in which case it's a matter of counting them yourself, eg. on the login and logout steps, or whatever matches your application.

+2


source







All Articles