On Sun, 09 Apr 2000, hal at finney.org wrote: > 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?
I want to be able to close the stream, but I want to do so in a non destructive manner. If you just let it go on into the RawMessage and let it lock on the next read there after reading one message, then the only way to close the ConnectionHandler is to just force the connection closed, while it could be reading a message. Say for example that DataReply generated a TimedOut when it ran out of HTL (it doesn't, but it could). The TimedOut would have KeepAlive=false, so you want to close the stream after sending it - but you want to wait until the DataInsert itself had finished reading the trailing field. Currently this happens, closed just sets the closed variable, which tells the message loop in run() to terminate rather then listen for another message after finnishing with this one. But read() gives you no knowledge of whether it is actually reading or locked and waiting. And if it is waiting on a read(), setting the "closed" variable to true won't do anything, because, since the other computer is probably not expected to send any more messages, it will sit there forever. Hence the way I did it now, where, while waiting, it pops up every 50 millis to check that the closed variabel hasn't been set to true. But available() returns the same 0 for open streams with nothing to read yet, and closed streams. And it seems the only way to check whether the socket or the stream is still open is to actually read from it. Which is why you have to use setSoTime() to say that read too should pop up to check whether to stop while waiting. But the actual reading is done in the RawMessage, which doesn't see the closed() variable, which I why I said one would have read in ConnectionHandler and then pushback for the RawMessage to read... > Hal > > _______________________________________________ > 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
