Sergey
Sergey

Reputation: 11918

Java sending TCP package broadcast from the server

There's a threaded TCP server which creates a new thread for each client connection. Is it necessary to store all the connections in array in order to send a broadcast to all of them?

Upvotes: 0

Views: 707

Answers (1)

user149341
user149341

Reputation:

Doesn't have to be an array, necessarily (it could be a hash or a tree or a bunch of threads with local variables..), but you do need to store all the connections somewhere in order to send to them. Otherwise they'd get GCed and closed.

Upvotes: 2

Related Questions