The UDP protocol was designed by David P. Reed in 1980. It allows applications to send messages called datagrams using a simple connectionless communication model with a minimal protocol mechanism, such as a checksum, for data integrity. It has no handshaking dialogs and, thus, does not guarantee message delivery or preserving the order of messages. It is suitable for those cases when dropping messages or mixing up orders are preferred to waiting for retransmission.
A datagram is represented by the java.net.DatagramPacket class. An object of this class can be created using one of six constructors; the following two constructors are the most commonly used:
- DatagramPacket(byte[] buffer, int length): This constructor creates a datagram packet and is used to receive the packets; buffer holds the incoming datagram, while length is the number of bytes to be...