<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 17, 2020 at 1:02 AM Stuart Douglas <<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div style="font-size:small">
Is there a way I can know when the client has received all the data, even if it is buffered at the system level?</div></div></div></blockquote><div><br></div><div>If you call flush() on the OutputStream is won't return until the client has recieved and acked the data AFAIK.</div></div></div></blockquote><div><br></div><div><div style="font-size:small" class="gmail_default">Alright, I tried this:<span class="gmail_default" style="font-size:small"><br></span></div><div style="font-size:small" class="gmail_default"><span class="gmail_default" style="font-size:small"><br></span></div>System.out.println("start");<br>PooledByteBuffer poolBuffer = exchange.getConnection().getByteBufferPool().getArrayBackedPool().allocate();<br>byte[] buffer = poolBuffer.getBuffer().array(); //
buffer<span class="gmail_default" style="font-size:small">.length </span><span class="gmail_default" style="font-size:small"></span><span class="gmail_default" style="font-size:small">is </span>16KB<span class="gmail_default" style="font-size:small">.</span><br>exchange.startBlocking();<br>OutputStream output = exchange.getOutputStream();<br>try (var input = new FileInputStream(file)) {<br> while (true) {<br> int count = input.read(buffer);<br> if (count == -1) break;<br> output.flush();<span class="gmail_default" style="font-size:small"> // Before write() to avoid flushing a closed OutputStream.</span><br> output.write(buffer, 0, count);<br> }<br>}<br>exchange.endExchange();<br>System.out.println("end");</div><div><br></div><div></div><div><div style="font-size:small" class="gmail_default">When I hit the URL, I see "start" and "end" printed immediately in the server log even though the
curl
download takes much, much longer at 10 bytes/sec.<br></div><div style="font-size:small" class="gmail_default"><br></div><div style="font-size:small" class="gmail_default">That was on Debian. Next I tried the same on Windows 10 and there I see only "start" while the download is in progress. That is true even if I remove the flush.<br></div></div><div><br></div><div><div style="font-size:small" class="gmail_default">So it seems it is something specific about Debian or its configuration. Any idea what is happening, or other ideas on how I can know when the client has really received the data?<br></div></div><div><br></div><div><div style="font-size:small" class="gmail_default">Cheers,</div><div style="font-size:small" class="gmail_default">-Nate</div><br></div></div></div>