From 545bf807262a1227d4706492bc142bbe4d998ad2 Mon Sep 17 00:00:00 2001 From: fhanik Date: Fri, 13 Apr 2007 03:22:29 +0000 Subject: [PATCH] Updated with some useful info git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@528341 13f79535-47bb-0310-9956-ffa450edef68 --- webapps/docs/aio.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/webapps/docs/aio.xml b/webapps/docs/aio.xml index 2c5a0cb36..4a882bd25 100644 --- a/webapps/docs/aio.xml +++ b/webapps/docs/aio.xml @@ -72,7 +72,13 @@ Alternately, it is also possible to catch any exception, perform clean up on any data structure the servlet may be using, and using the close method of the event. It is not allowed to attempt reading data from the request - object outside of the execution of this method. + object outside of the execution of this method.
+ On some platforms, like Windows, a client disconnect is indicated by a READ event. + Reading from the stream may result in -1, an IOException or an EOFException. + Make sure you properly handle all these three cases. + If you don't catch the IOException, Tomcat will instantly invoke your event chain with an ERROR as + it catches the error for you, and you will be notified of the error at that time. +
  • EventType.END: End may be called to end the processing of the request. Fields that have been initialized in the begin method should be reset. After this event has been processed, the request and response objects, as well as all their dependent @@ -194,8 +200,8 @@ public class ChatServlet InputStream is = request.getInputStream(); byte[] buf = new byte[512]; do { - int n = is.read(buf); - if (n > 0) { + int n = is.read(buf); //can throw an IOException + if (n > 0) { log("Read " + n + " bytes: " + new String(buf, 0, n) + " for session: " + request.getSession(true).getId()); } else if (n < 0) { -- 2.11.0