{
Log.report( "--- restart2 ------------------------------" );
MyDataHandler dh = new MyDataHandler();
Tcp2Connection c = new Tcp2Connection( "tcp://127.0.0.1:"+port+"?TcpTransport.reconnectDelay=200", r );
c.setSession( dh );
c.start();
c.waitUp( TIMEOUT );
int n = 10;
int i = 0;
while (++i <= n)
{
// Log.report( "--- waitAccepted" );
SocketChannel t = lh.accepted.waitUntilNotEqAndSet( null, TIMEOUT, null );
Log.report( "accepted", "i", i,
"t.local", t.socket().getLocalSocketAddress(),
"t.remote", t.socket().getRemoteSocketAddress() );
assertWhat( What.UP, dh.what );
// Log.report( "up", "c.local", c.localAddress(), "c.remote", c.remoteAddress() );
assertEquals( t.socket().getLocalSocketAddress(), c.remoteAddress() );
assertEquals( t.socket().getRemoteSocketAddress(), c.localAddress() );
write( t, i );
assertWhat( What.DATA, dh.what );
assertNull( dh.xsender );
assertNotNull( dh.xbuf );
assertEquals( 1, dh.xbuf.length );
assertEquals( (byte) i, dh.xbuf[0] );
// Log.report( "c.shutingDownOutput" );
c.shutdownOutput();
// Log.report( "c.shutdownOutput" );
// Log.report( "t.reading" );
assertEquals( -1, read( t ) );
// Log.report( "t.eof" );
t.socket().shutdownOutput();
t.close();
t = null;
assertWhat( What.DOWN, dh.what );
// Log.report( "down" );
}
Thread t1 = new MonitorHarvester<SocketChannel>( lh.accepted );
t1.start();
Thread t2 = new MonitorHarvester<What>( dh.what );
t2.start();
Log.report( "stopping" );
c.stop();
c.waitDown( TIMEOUT );
Log.report( "stopped" );
t1.join();
t2.join();
}