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);
}
}
```

Computer Science & Information Technology

You might also like to view...

The original IBM Token Ring Network operated at

a. 4 Mbps b. 10 Mbps c. 16 Mbps d. 100 Mbps

Computer Science & Information Technology

Disk cache buffers are stored ________.

a) in main memory b) in a memory module attached to the disk drive c) on a disk interface controller d) all of the above

Computer Science & Information Technology

Although you can create several different types of files with Dreamweaver, the primary one used in the exercises in this book is the ____ extension.

A. .xml B. .html C. .xhtml D. .jsp

Computer Science & Information Technology

Which tags are used to provide alternate content for users who have disabled scripts in their browsers?

a. b. c. < /no script> d. there are no such tags

Computer Science & Information Technology