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 ...

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.