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 their destinations is not guaranteed. Nor is the order of their arrival.
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
An application can send and receive DatagramPacket
s
through a DatagramSocket
.
In addition, DatagramPacket
s can be broadcast
to multiple recipients all listening to a MulticastSocket
.