On Fri, 31 Mar 2000, CacheMiss at aol.com wrote: > In a message dated 3/31/2000 5:44:04 AM Pacific Standard Time, > md98-osa at nada.kth.se writes: <snip> > I recently had this exact same problem in a different application I was > writing. I pulled out a significant amount of hair while screaming at > Java.... > > 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). > > -cm > > _______________________________________________ > Freenet-dev mailing list > Freenet-dev at lists.sourceforge.net > http://lists.sourceforge.net/mailman/listinfo/freenet-dev -- Oskar Sandberg md98-osa at nada.kth.se #!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj $/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1 lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/) _______________________________________________ Freenet-dev mailing list Freenet-dev at lists.sourceforge.net http://lists.sourceforge.net/mailman/listinfo/freenet-dev
