Hi everyone,

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

  Found this article: 
http://webtide.intalio.com/2013/07/servlet-3-1-async-io-and-jetty/ 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,
Richard

Code snippet:


class StandardDataStream implements WriteListener {....

  public void onWritePossible() throws IOException
  { byte[] buffer = new byte[4096];     // while we are able to write without 
blocking     while(out.isReady())
    {       // read some content into the copy buffer       int 
len=content.read(buffer);       // If we are at EOF then complete       if 
(len<0)
      {
        async.complete();
        return;
      }       // write out the copy buffer.        out.write(buffer,0,len);
    } } 
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to