简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM