tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastiaan van Erk <>
Subject Re: Another Comet 6.0.10 question
Date Wed, 04 Apr 2007 15:38:22 GMT
Ok, so I get a -1 on a read. Now what do I do?

If I just return from the event handler I immediately get another read 
:-(. If I close the event I can't do output anymore.

Can't it just send me ERROR/TIMEOUT events, just like what would happen 
if no READS arrive at all? In that case I can do async output (like in 
the Messaging application example). The CoyoteInputStream I called the 
read() on should know it reached the end of stream when I called read(), 
so why does it cause another READ event immediately even though it 
should know there is no more data? Shouldn't it behave in the same way 
that it would normally behave after handling a read event and there 
being no more data, i.e., do ERROR/TIMOUT events until the event is 
closed or new data arrives (which in this case can't happen)?


Rémy Maucherat wrote:
> On 4/4/07, Sebastiaan van Erk <> wrote:
>> Hi,
>> The pages on Comet say the following about the read event:
>> EventType.READ: This indicates that input data is available, and that
>> one read can be made without blocking. The available and ready methods
>> of the InputStream or Reader may be used to determine if there is a risk
>> of blocking: the servlet should read while data is reported available,
>> and can make one additional read without blocking. When encountering a
>> read error or an EOF, the servlet MUST report it by either returning
>> false or throwing an exception such as an IOException. This will cause
>> the error event to be invoked, and the connection will be closed. It is
>> not allowed to attempt reading data from the request object outside of
>> the execution of this method.
>> However, I just got a READ event where available() returns 0 (because
>> the next byte to read would be -1 indicating the end of the stream).
>> Is there any way to test for the end of the stream without calling 
>> read() ?
> Ok, that javadoc is a little bit out of date (ex: returning false).
> However, it is still valid: if you get a read event, you're supposed
> to do at least one read, and it could return -1 (if it got that from
> the client). If it fails to read data because the client disconnected,
> you'll get an IOException.
> Rémy
> ---------------------------------------------------------------------
> To start a new topic, e-mail:
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message