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 14:50:02 GMT
I have been reading the EventType.READ explanation over and over again, 
and now I have even more questions.

1) It says I should return false or throw an IOException when I get EOF. 
However, the event method has a void return type, so I don't know how to 
do the first. And if it's not unexpected it's not an error condition, 
and I don't want the error event to be invoked, so I can't throw an 
IOException. What do I do?

2) I keep getting READ events after reading all data from the stream 
(EOF reached). Now I don't want to close the event because I still want 
to write stuff, but I can't just return from the read event because I'll 
get another, causing a busy waiting loop. The bytes that need to be 
written arrive sporadically. How do I stop tomcat from causing READ 
events after the EOF while keeping the event open until the output is 
done as well.


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() ?
> Regards,
> Sebastiaan
> ---------------------------------------------------------------------
> 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