UDP-based communication
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 preserve the order of messages. It is suitable for those cases when dropping messages or mixing up orders are preferred instead of waiting for retransmission.
A datagram is represented by the java.net.DatagramPacket
class. An object of this class can be created using one of the 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, whilelength
is the number of bytes to be read.DatagramPacket(byte[] buffer, int length, InetAddress address, int port)
: This...