Recent Changes - Search:

Distributed Computing

This website demonstrates using wikis as teaching and learning tool.

The course instructor is also happy to share the teaching materials here with those who find it readable.

Suggested Answers to Tutorial

Tutorial : Daytime Client and Server (UDP)


Questions and Answers

  • 1. List the four methods of DatagramPacket to obtain information on the UDP packet that has received.
The four methods are: getAddress, getData, getLength, and getPort.
  • 2. List the four methods to set the DatagramPacket properties for transmission.
The four methods are: setAddress, setData, setLength, and setPort.
  • 3. Which type of exception objects may be thrown by the various constructors of class DatagramSocket?
Exception of type SocketException.
  • 4. What is the function of the method setSoTimeout(int timeout)?
It is used to specify the number of milliseconds that the receive() method waits to receive a UDP packet, after which it aborts with an InterruptedIOException.
  • 5. List the three methods to set properties of a DatagramSocket object.
The three methods are: setReceiveBufferSize, setSendBufferSize, and setSoTimeout.
  • 6. List the five methods to return properties of a DatagramSocket object.
The five methods are: getLocalAddress, getLocalPort, getReceiveBufferSize, getSendBufferSize, and getSoTimeout.
  • 7. What happens if you create a DatagramSocket without specifying a port number?
The operating system assigns an unused port to the DatagramSocket.
  • 8. Is it possible to use a single DatagramSocket for both sending and receiving purposes?
Yes.
  • 9. If you intend to create a DatagramSocket for receiving UDP packets first, is it possible to let the operating system assign an unused UDP port to you?
No. You must specify a port number known to other people so that they can send packets to you.
  • 10. If you have no idea about the size of the packet you are going to receive, how do you set the length of the DatagramPacket?
Set the length of the DatagramPacket object to be 65508, which is the maximum size of any UDP packet.
  • 11. In the process of receiving UDP packets, which step involves blocking I/O functions?
Step 3: the method receive() of DatagramSocket blocks until it has successfully received a packet or a timeout occurs.
  • 12. If you intend to send a number of different UDP packets to a single host by repeatedly calling the send method of the DatagramSocket, what should you do before each calling of the send method?
Normally, you should change the data payload and the payload length of your created DatagramPacket object, using the methods setData and setLength of DatagramPacket.
Edit - History - Print - Recent Changes - Search
Page last modified on November 28, 2008, at 04:32 PM