Channel support for UDP
The DatagramChannel
class provides additional support for UDP. It can support nonblocking interchanges. The DatagramChannel
class is derived from the SelectableChannel
class that makes multithreaded application easier. We will examine its use in Chapter 7, Network Scalability.
The DatagramSocket
class binds a channel to a port. After this class is used, it is no longer used directly. Using the DatagramChannel
class means, we do not have to use datagram packets directly. Instead, data is transferred using an instance of the
ByteBuffer
class. This class provides several convenient methods to access its data.
To demonstrate the use of the DatagramChannel
class, we will develop an echo server and client application. The server ...
Get Learning Network Programming with Java 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.