AsynchronousSocketChannel still throws unspecified exception

Alan Bateman Alan.Bateman at oracle.com
Wed Jul 13 04:44:22 PDT 2011


cowwoc wrote:
> :
> Alan,
>
> I've filed http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7063249
>
> Another two reasons I believe this must be fixed is that the existing
> specification makes it impossible to:
>
> 1. Ask the channel to return whatever data it has without waiting
> 2. As a consequence of #1, you can't ask the channel if it's in an error
> state without reading at least one byte
>   
Just to clarify, the methods that take a timeout do not wait. They are 
asynchronous like the other read/write methods and it's just a case that 
the I/O operations may have an associated timeout. If I understand your 
most recent mails then what you are asking for a way to read/write where 
the I/O operation is guaranteed to complete immediately, an asynchronous 
equivalent to a synchronous read/write where the channel is configured 
non-blocking. This would require a bit of consideration. It would 
clearly be more expensive, at least for implementations where the 
underlying I/O is blocking or asynchronous as such implementations would 
need to first poll the socket. An alternative, at least for the read 
case, is an "available" method.

-Alan.


More information about the nio-dev mailing list