Hi,
I am relatively new to
Java network programming, and would appreciate if anyone could point me to the right direction to the problem below:
A server S and three clients named A, B, and C respectively are on a network. A task is initiated by S, and is repeated for a number of times. For each run of the task, S sends a message to A, B, and C. Upon receiving the message, A, B and C are supposed to start their individual sub-tasks simultaneously, and finish working on the sub-tasks at the same time (this part can be controlled by a counter on the client side).
I am thinking S can broadcast the initial message to A, B, and C via sockets. However, how can we ensure that the clients A, B, and C all start at the same time (e.g. what if the message to A arrives slightly later than the ones to B and C because of some network issue?)
In addition, the clients will send some messages back to the server at end of each of their sub-tasks. So S should only initiate the next 'round' of communication after it receives all the messages from the clients in the current 'round'. I wonder how we can enforce such behavior.
Thanks!