QuestionQuestion

Description
An exactly-once service will guarantee a client’s request is processed at most once and at least once, provided the client does not fail. Your task in this assignment is to implement an exactly-once service in a client-server system. There is a single server in this system that supports multiple clients. This server must support non-volatile data and must recover from a crash.
Connection-less protocols do not guarantee message delivery. The protocol implementation is based on a “best try”. In this assignment you will design and implement your communication using datagrams.
The server’s exactly-once service must implement a data structure that will hold a five letter string. Initially the string is blank. When a client sends a successful request to the server, the server will modify its five-letter string in the following manner:
• Shift the first four characters of the server string to the right by one character.
• Store the character transmitted by the client in the first slot of the server’s string.
For example, the current value of the server string is “lmnop”. If the client passed in an “x”, the server would create a new string with the value “xlmno” and return this string to the client.

You must design and implement a test plan for the exactly-once service. This includes error/fault injection. The system must be able to handle a server crash and begin running from the point in which it ended. Thus, you must have a mechanism for starting a clean system as well as a system that has just recovered from a crash. The client and server will display their activities to the screen and contain a logging mechanism.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.io.*;
import java.net.*;

/*
* Client Program
*/
public class Client {

public static final String HOST = "localhost";
public static final int PORT = 8888;

// Main method for program execution
public static void main(String args[]) throws IOException{
// Launch client
try {
// Initialize socket
Socket socket = new Socket(HOST, PORT);
// Initialize socket read and write
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedReader is = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter os = new PrintWriter(socket.getOutputStream());
System.out.println("Client Program");
System.out.println("---------------------------");
System.out.println("Connected to " + HOST + ":" + PORT);
System.out.println("---------------------------");
// Query input from user
while(true){
System.out.println("Enter character to send to server (or empty line to quit): ");
String line = br.readLine();
// If empty input, quit
if (line.length...

By purchasing this solution you'll be able to access the following files:
Solution.docx and Solution.zip.

$100.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Computer Science - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats