Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete Java program by creating Multicast client-server classes(by usi

ID: 3669694 • Letter: W

Question

Write a complete Java program by creating Multicast client-server classes(by using MulticastSocket()) to do the following:

There are number of clients. Each one send an integer to the server.The server adds these integers.When the server receives a zero from a client it displays the sum of all the integers and terminates. For example if the first client sends 10, the second client sends 20, and the third client sends zero the server displays 30 and terminates.

PLEASE SEND ME THE CORRECT SOLUTION ASAP. I'M LOOKING FOR THE EXACT ANSWER, NOT LIKE HOW SERVER/CLIENT SEND/RECEIVE PACKETS

Explanation / Answer

Server
  

public class JavaServer {
public Integer sum(int x, int y){
return new Integer(x+y);
}
public static void main (String [] args){

try {
System.out.println("Attempting to start XML-RPC Server...");

WebServer server = new WebServer(80);
server.addHandler("sample", new JavaServer());
server.start();
System.out.println("Started successfully.");
System.out.println("Accepting requests. (Halt program to stop.)");

} catch (Exception exception){
System.err.println("JavaServer: " + exception);
}
}
}


client
import java.util.*;
import org.apache.xmlrpc.XmlRpcConfig;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.common.XmlRpcController;
import org.apache.xmlrpc.common.XmlRpcWorkerFactory;
public class JavaClient extends XmlRpcClient {
public static void main (String [] args) {

try {
XmlRpcClient server;
server=new XmlRpcClient();
Vector params = new Vector();

params.addElement(new Integer(17));
params.addElement(new Integer(13));

Object result = server.execute("sample.sum", params);
int sum = ((Integer) result).intValue();
System.out.println("The sum is: "+ sum);
} catch (Exception exception) {
System.err.println("JavaClient: " + exception);
}
}
@Override
protected XmlRpcWorkerFactory getDefaultXmlRpcWorkerFactory() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public XmlRpcConfig getConfig() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote