Chapter    14

Completion of Socket Channel Functionality

Completion of socket channel functionality is JDK 7’s final contribution to NIO.2. The java.nio.channels package’s DatagramChannel, ServerSocketChannel, and SocketChannel classes have been extended to support binding and option configuration. Also, channel-based multicasting is supported. This chapter wraps up the book by introducing you to these capabilities.

Binding and Option Configuration

NIO’s DatagramChannel, ServerSocketChannel, and SocketChannel classes don’t completely abstract a network socket. To bind into the channel’s socket, or to get/set socket options, you have to first retrieve the peer socket by invoking each class’s socket() method.

This counterintuitive mix of socket ...

Get Java I/O, NIO and NIO.2 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.