Summary
In this chapter, we examined the use of the NIO's channel and buffer classes. A channel connects to an external source and transfers data to and from a buffer. We illustrated channel sockets, which connect to another socket across the network.
Buffers are temporary repositories for data. Using a buffer allows data to be accessed either sequentially or randomly. There are many buffer operations, which makes this a good choice for many applications.
We examined several types of channel sockets, including the SocketChannel, ServerSocketChannel, and AsynchronousSocketChannel classes. The ServerSocketChannel class supports a server and uses an accept method to block until a client requests a connection. The method will return a SocketChannel ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access