Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] jetty-9.1 -- ServletOutputStream.isReady() -- how much data can be written without blocking?

Hi everyone,

  I was looking into the Servlet-3.1 implementation for truly non-blocking IO.

  Found this article: by Simone Bordet.

  The Servlet-3.1 ServletOutputStream provides simple boolean isReady() method to find out is the stream
  is ready to receive some data to write to the client, but it is unclear how much data can be written without blocking.

  I.e. if we do large enough write in subsequent out.writ(buffer, 0, len), it would block? Or not?

  Can anybody clarify this?

Thank you,

Code snippet:

class StandardDataStream implements WriteListener {
  public void onWritePossible() throws IOException
    byte[] buffer = new byte[4096];

    // while we are able to write without blocking
      // read some content into the copy buffer

      // If we are at EOF then complete
      if (len<0)

      // write out the copy buffer.  

Back to the top