directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven E. Harris" <...@panix.com>
Subject Trouble with WriteFuture.join() after IoSession.write()
Date Mon, 18 Dec 2006 04:29:06 GMT
I'm having trouble getting MINA to send outgoing data with the
IoSession.write() method. When I save the WriteFuture returned by
write() and attempt to call join() on the future, my program hangs. If
I don't call join(), my IoHandler.messageSent() method does get
called, and the data does go out as intended.

I started with the netcat example┬╣ and changed it only in the
IoHandler.sessionOpened() method, forcing some bytes to be written out
to provoke a response from the server:

,----
|    public void sessionOpened(IoSession session) throws Exception {
|       session.setIdleTime( IdleStatus.READER_IDLE, 10 );
| 
|       final byte[] CRLF = new byte[] { 0x0D, 0x0A };
|       final ByteBuffer buffer = ByteBuffer.allocate( 256 );
|       buffer.setAutoExpand( true );
|       final java.nio.charset.CharsetEncoder ce = java.nio.charset.Charset.defaultCharset().newEncoder();
|       buffer.putString( "GET http://www.w3.org/ HTTP/1.1", ce );
|       buffer.put( CRLF );
|       buffer.putString( "Host: www.w3.org", ce );
|       buffer.put( CRLF );
|       buffer.put( CRLF );
|       final org.apache.mina.common.WriteFuture future = session.write( buffer.flip() );
|       future.join();
|     }
`----

If I comment out the future.join() call, the program works fine.

This behavior occurs with the MINA trunk source (revision 488118)
running on Java SE 6 (1.6.0) on Windows XP.

Am I using WriteFuture.join() incorrectly()?


Footnotes: 
┬╣ http://svn.apache.org/viewvc/mina/trunk/example/src/main/java/org/apache/mina/example/netcat/

-- 
Steven E. Harris


Mime
View raw message