Hello list,

I've posted here a request for help a few days ago but only got 1 reply,
which did not get me very far. I'll try explaining my problem again, in the
hope of getting some more help.

I need to put up a server that handles client requests. Each client connects
via TCP to the server and then they exchange messages. The messages are
built as a PDU wrapping  an XML message.

Looking at the examples I got with MINA, it seems that the best option is
using a StreamIoHandler (decision 1). When doing that I ran into some
problems:

The processStreamIo method starts a new thread to handle the incoming data.
This thread reads the input stream and decodes the incoming messages. The
first problem was stopping this thread when the sessionClosed method is
invoked, because the read methods are blocking. I solved this by closing the
session's InputStream when the sessionClosed method is invoked, thus causing
the reading thread to throw an IOException and then terminating the
readingloop (decision 2). This seemed to work OK, until I had a client
that sent me
a single message and then closed the TCP connection quickly (hit and run).
This caused my former mechanism to close the InputStream before the new
thread had a chance to read the message and decode it.

OK, I hope all this clear.

Can anyone tell me what I did wrong and how I should solve this?

Thanks,

Zohar.

Reply via email to