tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Hanik - Dev Lists <>
Subject Re: svn commit: r533881 - /tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/chat/
Date Thu, 03 May 2007 01:51:49 GMT
Remy Maucherat wrote:
> 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 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.
correct, but what does available() return on a client disconnect, since 
in NIO it's detected as a read. Are we coding it such that when a read 
event happens, available() always return -1

> Rémy
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message