Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 13923 invoked from network); 1 May 2007 15:11:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 May 2007 15:11:08 -0000 Received: (qmail 16437 invoked by uid 500); 1 May 2007 15:11:10 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 16229 invoked by uid 500); 1 May 2007 15:11:10 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 16218 invoked by uid 99); 1 May 2007 15:11:10 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 May 2007 08:11:10 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [212.27.42.36] (HELO smtp6-g19.free.fr) (212.27.42.36) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 May 2007 08:11:03 -0700 Received: from [192.168.0.1] (gou06-1-82-224-99-120.fbx.proxad.net [82.224.99.120]) by smtp6-g19.free.fr (Postfix) with ESMTP id B032D6D49C for ; Tue, 1 May 2007 17:10:41 +0200 (CEST) Message-ID: <4637586F.5070608@apache.org> Date: Tue, 01 May 2007 17:10:39 +0200 From: Remy Maucherat User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Tomcat Developers List Subject: Re: svn commit: r533881 - /tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/chat/ChatServlet.java References: <20070430233611.6357C1A9838@eris.apache.org> <463751DA.8080808@hanik.com> In-Reply-To: <463751DA.8080808@hanik.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Filip Hanik - Dev Lists wrote: > question about this one, > since a client disconnect is signaled by a READ for the NIO connector, > and the only way to find out if the client was disconnected, the > InputStream.read() is supposed to return -1, how does that work with the > is.available()? For a client disconnect, you'll get an IO exception during the read, not a -1. The only situation where you'll get a -1 (that I know about) is for the end of the request body, for example if the content-length header says 10, and 10 bytes of the body have been read (so bytes may still be available on the socket, but they belong to the next request). Ideally, there would be a way to detect a disconnect in the poller so that the correct event is sent (this would avoid most IO exceptions, which is IMO much cleaner and more efficient). I understand available() as "there's something to read, and it won't block". It also allows enforcing the rule saying that the servlet must read all the stuff that is available when it gets a read event, which doesn't hurt. Rémy --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org