Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
hello everybody,

There is a problem i encountered when i develop a project. The problem is my software must be deployed on four machines(four instances) and those instances communicate each other to acquire other instance's state and decide the state of itself, is there some protocol or methods to do such work? Does anyone have some suggestion? Sorry for my poor english. Thank you!

regards,

gsrbnr.
Posted
Updated 6-May-10 9:36am
v3
Comments
Moak 6-May-10 13:10pm    
Updated subject and tags, hope this is what you are looking for.
Member 3051621 9-May-10 5:14am    
Hi.
I use the analog of web service as the solution of my project, that is every instance get the state of other instances through RMI and decide the state of itself. But there are also some issue, since the state of every instance should be different, maybe some instances' state conflict and maybe network break off, so the combination of various possible state is huge, the question is how can i determine the state of one instance according to some rule-based methods? How can i use code to implement this situation? Just like this?

if(instance2.state == 'B' && instance3.state == 'C' && instance4.state == 'D')
{
instance1.state = 'A';
}
else if (instance2.state == 'B' && instance3.state == 'B' && instance4.state == 'E')
{
instance1.state = 'F';
}
else if (instance2.state == 'C' && instance3.state == 'A' && instance4.state == 'E')
{
}
...
...
...

Is there some algorithm to solve this problems?

regards,
gsrbnr.

Have you considered setting up one of the machines as a web service? Then all machines (including the one hosting the web service) can simply be given the machine name hosting the web service, and the service can then be a hub for passing communications between all connected clients?
 
Share this answer
 
Member 3051621 wrote:
those instances communicate each other to acquire other instance's state and decide the state of itself, is there some protocol or methods to do such work?

There is no protocol that I'm aware of, but you could use a multi purpose protocol like HTTP or XML-RPC[^] if you don't want to write your own. Regarding software design, I think you have two alternatives:

1) Client-server architecture, declare one of the PCs to be 'server' or 'super node', everyone else will need to connect to the server in order to change/receive states. This is probably the easiest way to implement, since there will be only one central instance that decides. If there is a network outage, clients have to automatically reconnect to the server and resync.
2) Peer-to-peer architecture. Everyone will connect to everyone else and exchange states with each other. This is harder to implement, since you will need to find a more robust algorithm that can handle conflicting information and network outages (and they will happen).

Member 3051621 wrote:
The combination of various possible state is huge, the question is how can i determine the state of one instance according to some rule-based methods?

I don't think there is a general mathematical solution to that, the algorithm depends on what you want to do (your projects requirements). For example there could be states that are dominant or differently weighted with each other.

Hope this helps! :)
 
Share this answer
 
v5
Hi,

I would recommend you to use either UDP or TCP sockets.

With TCP sockets, you would have one-to-one connections with sanity checks on the connection periodically and retransmissions handling.

With UDP sockets, you will be able to do broadcast from one point to many points, and this without the need of creating one-to-one connections. The bad side with this approach is the fact that you will have to create your own retransmision handling and keep-alive handling for your connections.

So, now, the first question becomes :
--> Do you need to send information from one point to many points or only on a one-to-one basis ???

Another question would be:
--> Do you need that information to be encrypted or not ???

Good luck !
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900