Program each of the three operations of the request-reply protocol, using UDP communication, but without adding any fault-tolerance measures
What will be an ideal response?
```
class Client{
DatagramSocket aSocket ;
public static messageLength = 1000; Client(){
aSocket = new DatagramSocket();
}
public byte [] doOperation(RemoteObjectRef o, int methodId, byte [] arguments){
InetAddress serverIp = o.getIPaddress();
int serverPort = o.getPort();
RequestMessage rm = new RequestMessage(0, o, methodId, arguments );
byte [] message = rm.marshall(); DatagramPacket request =
new DatagramPacket(message,message.length(0,serverIp, serverPort);
try{
aSocket.send(request);
byte buffer = new byte[messageLength];
DatagramPacket reply = new DatagramPacket(buffer, buffer.length);
aSocket.receive(reply);
return reply;
}catch (SocketException e){...}
}
]
Class Server{
private int serverPort = 8888;
public static int messageLength = 1000; DatagramSocket mySocket;
public Server(){
mySocket = new DatagramSocket(serverPort);
// repeatedly call GetRequest, execute method and call SendReply
}
public byte [] getRequest(){
byte buffer = new byte[messageLength];
DatagramPacket request = new DatagramPacket(buffer, buffer.length);
mySocket.receive(request); clientHost = request.getHost(); clientPort = request.getPort(); return request.getData();
}
public void sendReply(byte[]reply, InetAddress clientHost, int clientPort){
byte buffer = rm.marshall();
DatagramPacket reply = new DatagramPacket(buffer, buffer.length);
mySocket.send(reply);
}
}
```
You might also like to view...
Microsoft Word has a built-in thesaurus that enables you to look up ________
Fill in the blank(s) with correct word
The maximum number of rows and columns you can create by splitting a cell ____.
A. is 10 B. is 20 C. is 30 D. depends on the cell's width and height