You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Sungwon Jung <th...@gmail.com> on 2007/09/28 15:38:50 UTC

doDecode problem

Hello. I'm using MINA 1.1.2.

let me see my server code.

--
public class PacketReqAnalysis extends CumulativeProtocolDecoder
{
  protected boolean doDecode(IoSession session, ByteBuffer in,
ProtocolDecoderOutput out) throws Exception {
    int start = in.get() & 0xFF;
    if( start == 0xCC ) {
      // do something
      System.out.println( "IN" );
      return true;
    } else {
      System.out.println( "OUT" );
      return false;
    }
--

if client send message to server slowly(this mean, not very fast),
"if( start == 0xCC )" routine can catch message. (print "IN")

but if client send message to server very fast, "if( start == 0xCC )"
routine cannot catch message. (print "OUT")

is it normal problem?

Re: doDecode problem

Posted by Sungwon Jung <th...@gmail.com>.
Thank you.

1 message size is 24bytes.
so about 8 message per 1 sec is ok.
but 8 more message per 1 sec is not ok.

anyway I'll read protocol codec tutorial in the documentation page.
and if I get other question, mailing. :-)


On 9/28/07, Trustin Lee <tr...@gmail.com> wrote:
> On 9/28/07, Sungwon Jung <th...@gmail.com> wrote:
> > Hello. I'm using MINA 1.1.2.
> >
> > let me see my server code.
> >
> > --
> > public class PacketReqAnalysis extends CumulativeProtocolDecoder
> > {
> >   protected boolean doDecode(IoSession session, ByteBuffer in,
> > ProtocolDecoderOutput out) throws Exception {
> >     int start = in.get() & 0xFF;
> >     if( start == 0xCC ) {
> >       // do something
> >       System.out.println( "IN" );
> >       return true;
> >     } else {
> >       System.out.println( "OUT" );
> >       return false;
> >     }
> > --
> >
> > if client send message to server slowly(this mean, not very fast),
> > "if( start == 0xCC )" routine can catch message. (print "IN")
> >
> > but if client send message to server very fast, "if( start == 0xCC )"
> > routine cannot catch message. (print "OUT")
> >
> > is it normal problem?
>
> It's the problem of your codec.  In TCP/IP, a packet can be split into
> multiple packets and multiple packets can be merged into small number
> of packets.  We call it 'fragmentation and assembly'.  Therefore, your
> codec must consider such a situation.  Actually it's not really
> difficult to take account into that.  Please refer to our protocol
> codec tutorial in the documentation page.
>
> HTH,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6

Re: doDecode problem

Posted by Trustin Lee <tr...@gmail.com>.
On 9/28/07, Sungwon Jung <th...@gmail.com> wrote:
> Hello. I'm using MINA 1.1.2.
>
> let me see my server code.
>
> --
> public class PacketReqAnalysis extends CumulativeProtocolDecoder
> {
>   protected boolean doDecode(IoSession session, ByteBuffer in,
> ProtocolDecoderOutput out) throws Exception {
>     int start = in.get() & 0xFF;
>     if( start == 0xCC ) {
>       // do something
>       System.out.println( "IN" );
>       return true;
>     } else {
>       System.out.println( "OUT" );
>       return false;
>     }
> --
>
> if client send message to server slowly(this mean, not very fast),
> "if( start == 0xCC )" routine can catch message. (print "IN")
>
> but if client send message to server very fast, "if( start == 0xCC )"
> routine cannot catch message. (print "OUT")
>
> is it normal problem?

It's the problem of your codec.  In TCP/IP, a packet can be split into
multiple packets and multiple packets can be merged into small number
of packets.  We call it 'fragmentation and assembly'.  Therefore, your
codec must consider such a situation.  Actually it's not really
difficult to take account into that.  Please refer to our protocol
codec tutorial in the documentation page.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6