> > available() has the nice feature of not blocking.  However it will return 0 
> > even if the stream has been closed, like you noticed.  What I ultimately 
> > had 
> > to do was use setSoTimeout() on the Socket so it wouldn't block forever 
> > (and 
> > ignore the InterruptedIOExceptions), and use read(byte[]) which will return 
> > -1 if the stream has been closed (maybe -- it's been kind of flaky for me, 
> > ymmv).
>
> I tried using this to read into an array of length 0, but this just returns 0
> right away, so it is no good for us. The only thing left I can think of is to
> use a PushBackInputStream and read one byte and then bush it back when it 
> get's
> read. But, em, could it get any more annoying?
>
> Could someone smarter then me please fix this (ConnectionHandler.java - L56, 
> we
> need some way to if the connection has been lost for some reason since the
> stupid available() continues returning 0).

I looked at this but couldn't figure out the logic.  Why can't you just
fall into reading the stream in RawMessage, assuming that "closed"
is false?  Is it so that you can be interrupted from another thread?
Could you use thread.interrupt or thread.destroy from the other thread
to close this one down?

Hal

_______________________________________________
Freenet-dev mailing list
Freenet-dev at lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/freenet-dev

Reply via email to