title: How to set up a multicast/unicast environment where every member can broadcast to the group and also send specific data to specific members
body: <p>I am trying to design an application where I can have any number of computers communicating with each other. I'm hoping to do this in Java, as I would eventually like to make an android app. I'm fairly new to java and very new to socket programming. Here's an example of what I'm going for:</p>
  
  <p>I have three computers, a Raspberry Pi that is configured as a temperature controller, which uses a thermocouple and controls an SSR to heat something up based on the input. Another raspberry Pi configured as a temperature logger, which reads the temperature of a thermocouple but does not control anything. The third PC is a desktop that acts as a terminal and doesn't control or read anything and only acts to communicate with the others.</p>
  
  <p>The general workflow should be something like this:</p>
  
  <ol>
  <li><p>Each computer scans to find other PC's running the application.</p></li>
  <li><p>The user at one of the computer can choose one of the other computers to connect to.</p></li>
  <li><p>The chosen terminal sends the data it's tracking (temperature setpoint and actual temperature in the case of the controller) to the computer requesting the information at some interval.</p></li>
  </ol>
  
  <p>I would eventually like to implement something where the terminal being used can send commands (like to update the setpoint for a controller), but that can come later.</p>
  
  <p>My thoughts on how to accomplish this, as of now:
  For point #1, I can set up each machine up to multicast an object that indicates some information, such as the IP, a port for a unicast, what type of machine it is (controller, passive terminal, Temp logger, etc) and maybe a few other details that might be helpful.</p>
  
  <p>For point #2, I'm not really sure how to develop the list of available terminals based on the multicast. To be honest, I'm not 100% sure how multicast works, but I'm guessing I can gather the objects from all of the other machines and display them. Could someone provide some clarification on how multiple hosts broadcasting on a multicast group is handled by the various clients?</p>
  
  <p>For point #3, I'm thinking that for this point, the client uses the port and IP address to open a unicast connection with the intended host who then responds by periodically sending data to the client (ie temperature set point and values) until an exit signal is sent, at which point the socket connection is closed.</p>
  
  <p>So I guess my question is this: Does this approach make sense? Is there an easier way to do all this?</p>