Bug 28619 - NIO is incomplete
Summary: NIO is incomplete
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: 0.92
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2006-08-06 08:33 UTC by Casey Marshall
Modified: 2006-08-06 08:33 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Casey Marshall 2006-08-06 08:33:18 UTC
Our NIO implementation -- especially socket channels -- is currently incomplete; the implementation we have relies on plain, blocking-IO sockets to implement channel operations (and, it does this by relying on socket timeouts to "emulate" nonblocking behavior). This solution won't work for all cases.

Specific issues with the current implementation include nonblocking connects not working, and neither does detecting EOF on a nonblocking read.

I don't think it's possible, or at least, wise, to try to use PlainSocketImpl to implement nonblocking sockets; that code (aside from suffering from the target-native brain damage) is far too reliant on the blocking model, and it looks difficult to teach it to handle nonblocking IO too. The current implementation is, at best, barely adequate.

The best solution, that I can think of, is to put the maybe-blocking operations  (read, write, connect and accept) exclusively in the SocketChannelImpl class, to put the socket option manipulation in the PlainSocketImpl class, and to make blocking sockets just call to a private SocketChannel for IO operations.