Reputation: 351
I'm programming a chat using MulticastSocket
and I will count the number of clients joined on this.
try (MulticastSocket clientSocket = new MulticastSocket(PORT)) {
clientSocket.joinGroup(address);
Does MulticastSocket
have some function for this purpose?
Upvotes: 2
Views: 351
Reputation: 719346
It is not technically possible. The way that the IP multicast protocol works, the endpoints don't know what other endpoints are in a multicast group.
As this Wikipedia page describes it:
IP multicast operation does not require an active source to know about the receivers of the group. The multicast tree construction is receiver driven and is initiated by network nodes which are close to the receivers. IP multicast scales to a large receiver population. The IP multicast model has been described by Internet architect Dave Clark as, "You put packets in at one end, and the network conspires to deliver them to anyone who asks."
Upvotes: 3