8198372: API to create a SelectableChannel to a FileDescriptor

Alan Bateman Alan.Bateman at oracle.com
Wed Jun 20 12:24:31 UTC 2018

A requirement that comes up periodically is some way to create a 
SelectableChannel implementation that can be used with the built-in 
Selector implementations. It's a project in itself because the 
FileDescriptor representation is not exposed and because it requires 
bidirectional translations of events. An alternative approach for the 
common case of just read and write operations is to provide a simple API 
to create a SelectableChannel to a file descriptor.

The proposal here is to extend the JDK-specific jdk.net module with 
support for creating a SelectableChannel to an existing file descriptor. 
The resulting channel is associated with the default SelectorProvider 
and supports an operation-set of OP_READ and OP_WRITE. The API is as 
minimal ass possible, the only complexity is closing when the channel is 
registered with a Selector.

The webrev with the proposed API is here:


More information about the nio-dev mailing list