Bi-directional communication with 1 socket - how to deal with collisions?
Posted
by Zwei Steinen
on Stack Overflow
See other posts from Stack Overflow
or by Zwei Steinen
Published on 2010-04-22T01:43:02Z
Indexed on
2010/04/22
1:53 UTC
Read the original article
Hit count: 274
Hi,
I have one app. that consists of "Manager" and "Worker". Currently, the worker always initiates the connection, says something to the manager, and the manager will send the response.
Since there is a LOT of communication between the Manager and the Worker, I'm considering to have a socket open between the two and do the communication. I'm also hoping to initiate the interaction from both sides - enabling the manager to say something to the worker whenever it wants.
However, I'm a little confused as to how to deal with "collisions". Say, the manager decides to say something to the worker, and at the same time the worker decides to say something to the manager. What will happen? How should such situation be handled?
P.S. I plan to use Netty for the actual implementation.
Thank you very much in advance!
© Stack Overflow or respective owner