What do you mean by ok?

As far as i can see, the connection closes and writing data to the OutputStream should generate an IOException, but this isn't happening... :-(
The problem is that my servlet is inside a loop, and needs to know when the client closes the connection, so it can exit the loop and properly close the running thread and liberate memory and cpu resources.


If you say it's ok, it means that tomcat really buffers the data and only generate the IOException when this buffer is full, and that this behavior is ok.
Is there any way i can control this tomcat's behaviour, like reduce the size of the buffer? Or even disable this buffer? (better)


thanks!
Vitor
P.S.: (to avoid confusion) The original message was posted by Paulo, but i'm working with him.


Remy Maucherat wrote:

Paulo Pizarro wrote:

I have a servlet with a persistent connection open to a client (browser), and when the browser is closed or the user hits the stop button, the connection is closed, but the servlet isn't throwing the IOException when it should do it.
(i guess)


As i could notice, after about 8k of data being written to the client after the connection has been closed, the serlet gets the IOException.

I think that perhaps tomcat is buffering the data and only when this buffer is full the IOException is thrown, even when we make a explicit call to out.flush().
The strange thing is that when the connection is open, the client receives data in real time, with no buffering or very little buffering.


Has anyone ever had this problem? I tried to call the method response.setBufferSize(0), but it didn't work.

Below is the piece of code that writes the data to the ServletOutputStream.

ServletOutputStream out = response.getOutputStream();

public void send(String s) throws IOException {
                      out.write(s.getBytes(), 0, s.length());
                      out.flush();
}


I believe this works ok.




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to