title: Are writes from within a Tomcat 6 CometProcessor non-blocking
body: <p>I have a CometProcessor implementation that is effectively doing a Multicast to a potentially large number of clients.  When an event occurs that needs propagated to to all the clients, the CometProcessor will need to loop through the list of clients writing out the response.  If writing responses block then there is the possibility that potentially slow clients could have an adverse effect on the distribution of the event.  Example:</p>
  
  <pre><code>public class MyCometProcessor implements CometProcessor {
      private List&lt;Event&gt; connections = new ArrayList&lt;Event&gt;();
      public void onEvent(byte[] someInfo) {
          synchronized (connections) {
              for (Event e : connections) {
                  HttpServletResponse r = e.getHttpResponse();
  
                  // -- Does this line block while waiting for I/O --
                  r.getOutputStream().write(someInfo);
              }
          }
      }
  
      public void event(CometEvent event) {
          switch (event.getEventType()) {
          case READ:
              synchronzied (connections) {
                  connections.add(event);
              }
              break;
          // ...
          }
  
      }
  }
  </code></pre>
  
  <p><strong>Update</strong>: Answering my own question. Writes from a CometProcessor are blocking:</p>
  
  <p><a href="http://tomcat.apache.org/tomcat-6.0-doc/config/http.html" rel="nofollow noreferrer">http://tomcat.apache.org/tomcat-6.0-doc/config/http.html</a></p>
  
  <p>See the table at the bottom of the page.</p>