AsynchronousSocketChannel operation cancelling on b145
Alan Bateman
Alan.Bateman at oracle.com
Wed Jun 22 00:46:38 PDT 2011
Gian Franco Zabarino wrote:
> I've been testing this on b145, and after I cancel a read request by
> cancelling the Future, I can no longer use the
> AsynchronousSocketChannel for reading. On NIO I always had the
> opportunity to remove the key from the Selector, and then to register
> the SocketChannel with another selector... Is there anyway to do this
> using NIO.2? Sometimes I need to read for detecting if a Socket was
> disconnected, and sometimes I need to read for user input. Both reads
> have different CompletionHandler classes, and different timeout
> parameters
>
If I understand correctly then you are looking to separate the
"completed" and "failed" cases? Or maybe you mean if the connection
reaches end-of-stream (the peer has closed the connection gracefully),
or there is an I/O error (the peer has closed the connection abruptly
for example), then you want one completion handler invoked. If bytes are
read then you want a different completion handler invoked. There isn't
any way in this API to separate these cases so it means you will need to
specify a completion handler that handles both cases or else specify a
completion handler that dispatches to other handlers depending on the
result.
-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20110622/53e42ec9/attachment.html
More information about the nio-dev
mailing list