Hi Zohar,

On 3/14/06, Zohar Amir <[EMAIL PROTECTED]> wrote:
>
> Hello,
> I have an application that uses StreamIoHandler.  The processStreamIo
> method
> starts a new thread to handle the incoming data. This thread does
> something
> like:
>
>   public void run() {
>    try {
>     while (true) {
>      Message message = null;
>      message = Decoder.decode(inputStream);
>      System.out.print(message);
>     }
>    } finally {
>     session.close();
>    }
>   }
>
> The questions is how to break the thread loop when the session is closed.
> The solution should also handle clients that send short messages, so that
> the sessionClosed method is invoked before the thread is started and gets
> a
> chance to decode the sent message.


If you try to read from a closed session, it should throw an IOException.
So you could simply catch an IOException and break the loop.

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Reply via email to