Thank you. I forgot to call the flip method.

-----Mensaje original-----
De: Serkan Demir [mailto:[EMAIL PROTECTED] 
Enviado el: viernes, 11 de agosto de 2006 14:32
Para: [email protected]
Asunto: Re: ByteBuffer issue

are you flipping the buffer before writing?
http://directory.apache.org/subprojects/mina/faq.html#no-data-written

----- Original Message -----
From: "Miguel Alcon Pinto" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, August 11, 2006 2:11 PM
Subject: ByteBuffer issue


Hi,

I'm trying to use ByteBuffer to sent data via UDP (Mina 0.9.4 in a Windows 
2000 system)

If I use bf.putInt(1111) without position in the buffer it fails, I've to 
use bf.putInt(0,1111), always with the position in order to run correctly.
Do anyone what I'm doing wrong?

public static void main(String[] args) throws Exception{
DatagramConnector connector = new DatagramConnector();
        ConnectFuture cf=connector.connect(
                new InetSocketAddress( args[ 0 ],
                Integer.parseInt( args[ 1 ] ) ),
                new IoHandlerAdapter(){
                @Override
                public void exceptionCaught(IoSession session, Throwable 
cause) throws Exception {
                System.out.print("#");
                }
                }
                );

        IoSession session;
while(true){
            cf.join();
            session = cf.getSession();
System.out.print(".");
ByteBuffer bf= ByteBuffer.allocate(4,true);
bf.putInt(1111);
//bf.putInt(0,1111);
WriteFuture future =session.write(bf);
future.join();
Thread.sleep(500);
}

}

Thanks.

Best regards, Miguel.

--------------------------------------
Miguel Alcón Pinto
SGI Soluciones Globales Internet
C/ Isaac Newton 11
28760 Tres Cantos (Madrid), España
E-mail. [EMAIL PROTECTED]
http://www.sgi.es
-------------------------------------- 

______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.
______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.
______________________


______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.
______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.
______________________

Reply via email to