You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by playboyleekelin <pl...@163.com> on 2008/07/02 08:43:48 UTC

hi,how to send byte[] use mina?

 
 
hi,
 
     i need send byte[] with mina.
 
please give me demo?
 
 
 
                int blen = gkbPkg.createLoginRespPackage(1).length;
                System.out.println("------------------------> len:" + blen );
                ByteBuffer buf = ByteBuffer.allocate( blen ) ;
                if(buf!=null){
                    System.out.println("send...");
                    //buf.clear();
                    //bb.get(gkbPkg.createLoginRespPackage(1));
                    buf.put( gkbPkg.createLoginRespPackage(1) );
                    //buf.put((byte) '.');
                    //buf.flip();
                    //session.write(bb.duplicate());        
                    session.write(buf);         
                    //buf.clear();
                } 
 
Exception

Re: hi,how to send byte[] use mina?

Posted by Viktor Balázs <vi...@gmail.com>.
Maybe this example is working (I'm using MINA 2.0.0-M1):

        byte[] bytes = new byte[100];
>         Arrays.fill(bytes, (byte)65);


>
        IoBuffer buf = IoBuffer.allocate(64);
>         buf.setAutoExpand(true);
>
>         buf.put(bytes);
>
>         buf.flip();
>         session.write(buf);



2008/7/2 playboyleekelin <pl...@163.com>:

>
>
> hi,
>
>     i need send byte[] with mina.
>
> please give me demo?
>
>
>
>                int blen = gkbPkg.createLoginRespPackage(1).length;
>                System.out.println("------------------------> len:" + blen
> );
>                ByteBuffer buf = ByteBuffer.allocate( blen ) ;
>                if(buf!=null){
>                    System.out.println("send...");
>                    //buf.clear();
>                    //bb.get(gkbPkg.createLoginRespPackage(1));
>                    buf.put( gkbPkg.createLoginRespPackage(1) );
>                    //buf.put((byte) '.');
>                    //buf.flip();
>                    //session.write(bb.duplicate());
>                    session.write(buf);
>                    //buf.clear();
>                }
>
> Exception




-- 
Balázs Viktor
Amkai Kft. (1188 Budapest, Szövet u. 9.)

Email: viktor.balazs@gmail.com
Jabber: viktor.balazs@gmail.com
MSN: viktor.balazs@amkai.com
Telefon: +36-30/6755532