This is a very interesting problem that we've considered over at Apache
Directory. The idea of streaming to disk in some temporary area while
giving the user a stream to read from. This way the PDU could be streamed
to disk as the higher levels of the server business logic reads it from disk
with a final notification that the data is fully available.
Sometimes you just want to leave it on disk until you're ready to stream it
back out. In this case you want to just hand it off to MINA to write out
back to the client.
It sure would be nice for MINA to have these kinds of capabilities. This
way several kinds of DoS attacks on MINA servers can be prevented. Right
now it's pretty damn easy to crash a MINA server unless there is a way to
limit PDU sizes.
Alex
On Tue, Apr 29, 2008 at 9:14 AM, Atul Moglewar <[EMAIL PROTECTED]>
wrote:
> Hi,
> I'm developing a client server application, where server is socket
> server as well as an RMI server. The socket client sends binary data
> to to the server. I want to return the inputstream to the RMI client
> as the socket client starts writing it to the outputstream so that the
> socket server don't have to buffer the data. Is there any way to get
> the message as the InputStream in messageReceived function?
>
> I wrote following code in the doDecode function
>
> protected boolean doDecode(IoSession session, IoBuffer ib,
> ProtocolDecoderOutput out) throws Exception {
> int remaining = ib.remaining();
> if (remaining >= SIZE) {
> System.out.println("remaining = " + remaining);
> InputStream is = ib.asInputStream();
> out.write(is);
> return true;
> } else {
> return false;
> }
> }
>
> org.apache.mina.filter.codec.ProtocolDecoderException:
> java.lang.IllegalStateException: doDecode() can't return true when
> buffer is not consumed.
>
> Basically, the amount of data that is received can be huge, hence I
> don't want to buffer it at server and gives it to the RMI client as
> soon as the socket server starts receiving it.
> What shall I need to do if i want to receive the network stream in the
> messageReceived function, or is there any better way to accomplished
> the task?
>
> Thanks,
> Atul
>