On Tue, 27 Mar 2001 [EMAIL PROTECTED] wrote:

> I'm having problems with jakarta-tomcat-4.0-b1 (running on linux :)) and i can not 
>get IOEXceptions at all.
> 
> Servlet code:
> 
> try 
> {     
> ObjectOutputStream out = new 
>ObjectOutputStream(client.getSocket().getOutputStream());
> out.writeObject(new Integer(1));
> }
> catch (IOException e) 
> {
> removeClient(client);
> }
> 
> If client goes away, (browser is closed,etc...), execution of code stops to 
>out.writeObject()  Servlet blocks there forever. 
> 
> client class is an instance of my own SocketWrapper class.
> 
> Any hints?
> Thanks, weggi.
> 
> 
>  
> 
Because there could be (and in fact is) buffering going on between the
response stream and the underlying socket, the above code is not
guaranteed to have actually written anything by the writeObject() call
completes.  You can increase your chances of catching I/O errors if you
add an out.flush() call after the out.writeObject() call, but there are
still no guarantees (for example, if you were running Tomcat behind a
connector to Apache, Tomcat will never ever find out about the client
having gone away).

Craig McClanahan


Reply via email to