ServerSocket and number of clients

Hi all!

I have an issue: understand how many clients are connected to my serverSocket in a certain moment. I have a list of the clients who made the connection, but some of them lost their link with the server due to a ConnectionReset and the number of connections still alive sometimes (I cannot understand when) is not updated.

Is there a formal method to know how many clients are connected to a ServerSocket?

Thanks very much

[454 byte] By [albertthea] at [2007-11-27 0:48:58]
# 1
Every time you accept a socket increment a counter. Every time you close an accepted socket for any reason, including an exception, decrement the counter.
ejpa at 2007-7-11 23:18:13 > top of Java-index,Core,Core APIs...
# 2
obviously I do so, but something does not permit the update of the counter sometimes. For this reason I need a formal way to know how many clients are connected to the server...is there a way to do this? Searching the API I did not find anything
albertthea at 2007-7-11 23:18:13 > top of Java-index,Core,Core APIs...
# 3
There isn't anything. Check your code, and check the synchronization conditions too. If you account for every accepted and closed socket you can't get it wrong, and if you're getting it wrong you're not accounting for every accepted and closed socket.
ejpa at 2007-7-11 23:18:13 > top of Java-index,Core,Core APIs...