Reputation: 2086
I'm about to implement server/client communication via tcp/ip over the internet. The server and the client will be a bit chatty when trying to synchronize their states.
client: sends state
server: check state and request differences
client: sends 1 element
server: sends ack/nak
client: sends 1 element
server: sends ack/nak
.
.
.
etc.
What is the best way to implement this? Should I use raw Sockets? Should I use 2 connections, one for each direction? Should I use a framework? Any idea are appreciated.
Thanks
EDIT: What is the best way to implement this, when large load (gigabytes of data), stability and ease of implementation are prioritized?
.. and by the way there are no differents between the client and the server. They can shift role any time, and be the one to make the connection.
It could be nice to use a framework that handles reconnect etc.
Upvotes: 1
Views: 1665
Reputation: 54074
What is the best way to implement this, when large load (gigabytes of data), stability and ease of implementation are prioritized?
From my point of view these goals are hints to using a stable framework rather implementing a custom solution.
Look into Java web services (you can find plenty of examples by Googling) and have both the client expose a server interface as well.
I would recommend RESTful instead of SOAP services.
Upvotes: 1
Reputation: 235984
If both the client and the server are going to be Java programs, consider the alternative of using RMI:
The Java Remote Method Invocation (RMI) system allows an object running in one Java virtual machine to invoke methods on an object running in another Java virtual machine. RMI provides for remote communication between programs written in the Java programming language.
It's simpler than trying to implement your own protocol on top of sockets.
Upvotes: 1