Previous | Next | Trail Map | Custom Networking and Security | All About Datagrams


What Is a Datagram?

Clients and servers that communicate via a reliable channel (such as URL or socket) have a dedicated point-to-point channel between themselves (or at least the illusion of one). To communicate, they establish a connection, transmit the data, and then close down the connection. All data sent over the channel is received in the same order that it was sent. This is guaranteed by the channel.

In contrast, applications that communicate via datagrams send and receive completely independent packets of information. These clients and servers do not have and do not need a dedicated point-to-point channel. The delivery of datagrams to its destination is not guaranteed, nor is the order of arrival.


Definition: A datagram is an independent, self-contained message sent over the network whose arrival, arrival time, and content are not guaranteed.

The java.net package contains two classes to help you write Java programs that use datagrams to send and receive packets over the network: DatagramSocket and DatagramPacket. Your application sends and receives DatagramPackets through a DatagramSocket.

See also

java.net.DatagramPacket
java.net.DatagramSocket


Previous | Next | Trail Map | Custom Networking and Security | All About Datagrams