OK, did a quick check of the servlet spec - and I could find nothing that proscribes the kind of thing I was thinking about (in fact it has nothing to say even about the semantics of using the javax.servlet.ServletInputStream)
Here is some pseudocode for what I had in mind (I'm eliding quite a bit: void readSocket(SocketChannel sc) { ByteBuffer bb = .. while (requestIncomplete(bb)) { int bread = sc.read(bb); //non-blocking read if (bread == 0) // socket has no bytes in receive-buffer, need to re-register with selector { sc.keyFor(selector).interestOps(OP_READ) // 're-register socket with selector for reads return; } else if (bread == -1) // socket closed - clean up } //all bytes on socket (constituting an http request) have been read RequestExecutor r = ... r.execute(new Handler(bb)) } Note requestIncomplete() returns true only when the *entire* http request (headers and body) has been read. Now, this is idiomatic java nio and I have used this pattern in implementing my own nio server (not for http requests) I see nothing in the servlet spec that would proscribe this and it scales wonderfully. Yet it seems that Tomcats NIO connector does not do this. Hence, my confusion/curiosity -- View this message in context: http://tomcat.10.n6.nabble.com/Getting-my-head-around-NIO-simulated-blocking-trying-to-tp4996773p4996776.html Sent from the Tomcat - Dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org