AsynchronousSocketChannel.shutdownInput()
Gili
cowwoc at bbs.darktech.org
Tue Aug 4 20:27:28 PDT 2009
Alexander Libman wrote:
>
> write() must return the number of elements (chars, not bytes!) processed
> from the buffer(CharBuffer), i.e. consumed by encoder.
> How many bytes encoder produces on output(i.e. on internal channel ) is
> not
> important for the caller.
> "write () "is a job and "completed()" callback means the job is done.
> If write() completed with less bytes processed than requested, it should
> be
> called again.
> write() in TCP means data accepted for the trasnmission, but it does not
> mean data is delivered.
> It is up to decoder to buffer encoded data or to push them into internal
> channel.
> So shutdownOutput() works like flush and prohibits any future write
> operations.
> If error occurs during shutdownOutput() , exception should be thrown.
> If you are still worried about all data are transmitted on internal
> channel,
> you can wait in external channel close() the completion of all operations
> on internal channel.
>
Hi Alex,
To be honest I don't fully understand the implications of
CharsetEncoder.encode(endOfInput=true) and CharsetEncoder.flush(). If I
write() 5 characters with endOfInput = false,
1) What's the point of CharsetEncoder.flush() if write(endOfInput=true)
already knows that you're flushing? Is it because flush() is overridable by
subclasses whereas encode() is not?
2) Am I guaranteed that the total characters outputted by
CharsetEncoder.write() and flush() will be equal to 5 characters? I ask
because the specification for flush() makes it seem as if there is no limit
to the number of bytes it could output.
3) If I want to implement a method similar to OutputStream.flush() on top of
CharsetEncoder, how would I do it? write(endOfInput=true) and flush() cannot
be invoked more than once, whereas OutputStream.flush() can. But if I don't
invoke them am I really flushing?
Alexander Libman wrote:
>
> Yes, I know - it is still a draft, but it is working draft and I hope
> the
> code is not hard to read.
> We will definetely try to find time to write better comments/doc.
>
Okay. I will try to finalize my implementation in the coming weeks. Once
that's done we'll discuss folding it into nio2 or your framework. I'd like
to hand maintenance over to someone else once I finish the stabilizing the
code.
Gili
--
View this message in context: http://n2.nabble.com/AsynchronousSocketChannel.shutdownInput%28%29-tp3365782p3388926.html
Sent from the nio-discuss mailing list archive at Nabble.com.
More information about the nio-discuss
mailing list