7176630: (sc) SocketChannel.write does not write more than 128k when channel configured blocking [win]
Zhong Yu
zhong.j.yu at gmail.com
Thu Jun 14 10:28:04 PDT 2012
On Thu, Jun 14, 2012 at 11:24 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>> Alan, if a short write occurs in blocking mode, what is the caller
>> supposed to do? Apparently it's not an error condition, so the caller
>> can immediately try write() again on the remaining bytes?
>>
> Normally you won't see short writes in blocking mode. The only "normal"
> case, that I'm aware of anyway, is on Windows where you you attempt to write
> with >= 128k bytes remaining in the buffer and that is the case that this
> patch attempts to smooth over. There are one or two cases odd cases, say
> where someone does write(ByteBuffer[]) with an array of hundreds of buffers,
> more than IOV_MAX. I think the only thing we can do is set expectations in
> the javadoc and that is something I plan to do.
I must be missing something - but in blocking mode, whatever the
reason for short write is, why can't write() loop internally, return
only when all bytes are written? Why is it necessary to report the
short write to caller, who then has to loop externally?
More information about the nio-dev
mailing list