UDP socket programming | DatagramPacket DatagramSocket | UDP client-server | tutorial -51 | 2020

Опубликовано: 18 Март 2026
на канале: Pushpendra Kumar
9,641
82

DatagramPacket and DatagramSocket :(Creating simple UDP client-server)
UDP Sockets are less complex and have lesser overheads in comparison to TCP. For UDP connections DatagramPacket and DatagramSocket are two main classes in java.net package. DatagramPacket class implements the mechanism to contain (it is a container for the data)  data, so it can be considered as a data container. DatagramSocket class is the mechanism used to establish the communication using the UDP protocol.
The DatagramSocket class represents a connection less socket for sending and receiving the data packets. The UDP protocol does not offer guarantee that the content will be delivered, as no acknowledgement is provided by the receiver.