Chapter 13. Broadcasting events with UDP
This chapter covers
- An overview of UDP
- A sample broadcasting application
Most of the examples you’ve seen so far have used connection-based protocols such as TCP. In this chapter we’ll focus on a connectionless protocol, User Datagram Protocol (UDP), which is often used when performance is critical and some packet loss can be tolerated.[1]
1One of the best-known UDP-based protocols is the Domain Name Service (DNS), which maps fully qualified names to numeric IP addresses.
We’ll start with an overview of UDP, its characteristics and limitations. Following that we’ll describe this chapter’s sample application, which will demonstrate how to use the broadcasting capabilities of UDP. We’ll also make use of an encoder and a decoder to handle a POJO as the broadcast message format. By the end of the chapter, you’ll be ready to make use of UDP in your own applications.
Connection-oriented transports (like TCP) manage the establishment of a connection between two network endpoints, the ordering and reliable transmission of messages sent during the lifetime of the connection, and finally, orderly termination of the connection. By contrast, in a connectionless protocol like UDP, there’s no concept of a durable connection and each message (a UDP datagram) is an independent transmission.