Package etch.util.core.nio

Examples of etch.util.core.nio.Tcp2Connection


  @Test
  public void data2() throws Exception
  {
    MyDataHandler dh = new MyDataHandler();
   
    Tcp2Connection c = new Tcp2Connection( "tcp://127.0.0.1:"+port, r );
    c.setSession( dh );
   
    assertFalse( c.isStarted() );
    c.start();
    assertTrue( c.isStarted() );
   
    SocketChannel t = lh.accepted.waitUntilNotEqAndSet( null, TIMEOUT, null );
   
    assertWhat( What.UP, dh.what );
    assertNull( dh.xsender );
    assertNull( dh.xbuf );
   
    byte[] buf = { 21, 22, 23 };
   
    write( t, buf );
   
    assertWhat( What.DATA, dh.what );
    assertNull( dh.xsender );
    assertNotNull( dh.xbuf );
    assertEquals( 3, dh.xbuf.length );
    assertEquals( (byte) 21, dh.xbuf[0] );
    assertEquals( (byte) 22, dh.xbuf[1] );
    assertEquals( (byte) 23, dh.xbuf[2] );
   
    assertTrue( c.isStarted() );
    c.stop();
    assertFalse( c.isStarted() );
   
    assertWhat( What.DOWN, dh.what );
    assertNull( dh.xsender );
    assertNull( dh.xbuf );
   
View Full Code Here


  @Test
  public void data3() throws Exception
  {
    MyDataHandler dh = new MyDataHandler();
   
    Tcp2Connection c = new Tcp2Connection( "tcp://127.0.0.1:"+port, r );
    c.setSession( dh );
   
    assertFalse( c.isStarted() );
    c.start();
    assertTrue( c.isStarted() );
   
    SocketChannel t = lh.accepted.waitUntilNotEqAndSet( null, TIMEOUT, null );
   
    assertWhat( What.UP, dh.what );
    assertNull( dh.xsender );
    assertNull( dh.xbuf );
   
    t.socket().shutdownOutput();
   
    assertWhat( What.DOWN, dh.what );
    assertNull( dh.xsender );
    assertNull( dh.xbuf );
   
    t.close();
    c.close();
  }
View Full Code Here

  @Test
  public void data4() throws Exception
  {
    MyDataHandler dh = new MyDataHandler();
   
    Tcp2Connection c = new Tcp2Connection( "tcp://127.0.0.1:"+port, r );
    c.setSession( dh );

    c.start();
   
    SocketChannel t = lh.accepted.waitUntilNotEqAndSet( null, TIMEOUT, null );
   
    assertWhat( What.UP, dh.what );
    assertNull( dh.xsender );
    assertNull( dh.xbuf );
   
    c.transportData( null, new FlexBuffer( new byte[] { 21, 22, 23 } ) );
//    c.flush();
   
    assertEquals( 21, read( t ) );
    assertEquals( 22, read( t ) );
    assertEquals( 23, read( t ) );
   
    c.shutdownOutput();
   
    assertEquals( -1, read( t ) );
   
    c.close();
   
    assertWhat( What.DOWN, dh.what );
    assertNull( dh.xsender );
    assertNull( dh.xbuf );
   
View Full Code Here

TOP

Related Classes of etch.util.core.nio.Tcp2Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.