I have scenario where there is one server application and many clients. The clients need to be able to send messages to the server which is simple and covered in the Client-Server tutorial. I also need the server to be able to send messages out to all the clients. What would be the best way to accomplish something like this? Would it make sense to do a UDP broadcast for all the clients to pick up? Is there any type of tutorial that shows two-way communication? Thanks.
UDP broadcast should work on Android but you will have to use the subnet specific broadcast address, ie something like 192.168.1.255 (depending on your ip configuration) instead of 255.255.255.255. If this isn’t working we definitely would like to know so if you could confirm that would be appreciated.
UDP broadcast can be quite spammy (in terms of overall network load) so if the number of clients is small you are probably better just looping over the connections in your server side code and sending the packet to each client. Which performs better will depend on the specifics of your network and what you’re sending so you will probably want to experiment. It’s also worth noting that UDP broadcasts ‘can’ be tricky to debug if there is an issue.