5.9. Summary

The User Datagram Protocol (UDP) provides a connectionless transport mechanism that allows packets of data to be sent to remote machines. UDP generates less overhead than other transport protocols and is highly desirable for real-time broadcasting of multimedia such as audio, video, and network gaming data. However, due to its lack of guaranteed delivery and sequencing, it creates additional work for developers, and thus the pros and cons of its use must be considered on a case-by-case basis.

Java supports UDP in the form of the DatagramSocket and DatagramPacket classes. In order to send or receive packets, an application must bind to a local port using DatagramSocket. The application creates a DatagramPacket with a sufficient buffer ...

Get Java™ Network Programming and Distributed Computing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.