?
Solved

Implementation of a Protocol for Server/Client communication

Posted on 2007-09-29
2
Medium Priority
?
245 Views
Last Modified: 2013-11-23
I am trying to program a Server/Client application in which I have to implement a protocol for them to communicate. The server is supposed to load an address book from a file, and then allow the client to add/delete from it.  I have the server and client classes and I created a protocol class that recognizes the messages from the client, but I am a little confused on the correct way to do the add/delete to the file.  The way that I am structuring it is that the client sends a command to the server, the server then passes this message to a method in the protocol class.  The server also loads the file when it starts.  So is the correct process then to just return a value from the protocol indicating the type of command for the server to do on the file, and then proceed from there?  I don;t think the protocol class should write to the file, but I am a little confused on which class should write to the file.  Thank you!
0
Comment
Question by:eric68
1 Comment
 
LVL 14

Accepted Solution

by:
nayernaguib earned 300 total points
ID: 19987168
I would delegate the I/O work to a "persistence manager" class implementing a generic I/O interface. This makes it easier to modify the persistence method without changing server/protocol code. For example, you might later decide to store the address book in a database rather than a file. In this case you will only need to create and instantiate a new class implementing the generic I/O interface, and use it in place of the filesystem I/O class. You can instantiate your I/O classes by creating a factory class that will return an instance of a persistence manager of a specific type that is provided as a parameter to the Factory.getInstance() method.

_______________

  Nayer Naguib
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Creating an OSPF network that automatically (dynamically) reroutes network traffic over other connections to prevent network downtime.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question