Search code examples
javaclassdatagram

3 classes in Java which implement system independent datagram communication?


I'm revising for a network exam and this is one of the questions in a few past papers.

Name 3 classes in Java which implement system independent datagram communication?

I was led to believe there were only 2 class to implement system independent datagram communication;

  • DatagramPacket
  • DatagramSocket

What could the 3rd class be?

Answers greatly appreciated


Solution

  • The java.net package contains three classes to help you write Java programs that use datagrams to send and receive packets over the network:

    DatagramSocket, DatagramPacket, and MulticastSocket

    public class MulticastSocket extends DatagramSocket

    An application can send and receive DatagramPackets through a DatagramSocket. In addition, DatagramPackets can be broadcast to multiple recipients all listening to a MulticastSocket.

    The multicast datagram socket class is useful for sending and receiving IP multicast packets. A MulticastSocket is a (UDP) DatagramSocket, with additional capabilities for joining "groups" of other multicast hosts on the internet.

    A multicast group is specified by a class D IP address and by a standard UDP port number. Class D IP addresses are in the range 224.0.0.0 to 239.255.255.255, inclusive. The address 224.0.0.0 is reserved and should not be used.