Channel support for UDP
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.
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 ...