The CompletionHandler<V,A> Interface in Asynchronous context

Alan Bateman Alan.Bateman at Sun.COM
Thu Nov 12 01:21:33 PST 2009

向雅 wrote:
> Hi,
> The CompletionHandler interface have notification method:
> 	public void completed(Integer result, T attachment);
> In common case, read and write operation coding seems OK.
> In most code, if handle the read operation, you should or must handle
> result==-1 case.
> And even if result==-1, maybe you still need check the read buffer to
> see if have some incoming data.
If the completed method is called to notify you of EOF then you are 
guaranteed that no bytes have been read. In order words, the result is 
always the number of bytes read or -1 to indicate EOF.

If I understand your proposal correctly then you are proposing that we 
don't report the number of bytes read - is that right?


More information about the nio-dev mailing list