Examples of TcpConnection


Examples of ch.usi.dslab.bezerra.netwrapper.tcp.TCPConnection

public class SimpleTcpClient {

   public static void main(String[] args) throws InterruptedException, IOException {
      Message message = new Message(new String("message from client"));
      System.out.println("Message class name: " + Message.class.getName());
      TCPConnection serverConnection = new TCPConnection("localhost", 50000);
      serverConnection.sendBusyWait(message);

      Message rawReply = serverConnection.receiveBusyWait();
      String reply = (String) rawReply.getItem(0);
      System.out.println("Reply received: " + reply);
   }
View Full Code Here

Examples of ch.usi.dslab.bezerra.netwrapper.tcp.TCPConnection

   public static void main(String[] args) throws InterruptedException, IOException {
      TCPSender sender = new TCPSender();
     
      Message message = new Message(new String("first message from client"));
      TCPConnection serverConnection = new TCPConnection("localhost", 50000);

      sender.send(message, serverConnection);

      TCPReceiver receiver = new TCPReceiver();
      receiver.addConnection(serverConnection);
View Full Code Here

Examples of com.firefly.net.support.TcpConnection

    private final SimpleTcpClient client;
    private final CyclicBarrier barrier;

    @Override
    public void run() {
      TcpConnection c = client.connect();
      try {
        for (int i = 0; i < LOOP; i++) {
          String message = "hello world! " + c.getId();
          String ret = (String) c.send(message);
          log.debug("rev: {}", ret);
        }
      } finally {
        if (c != null)
          c.close(false);
      }
      log.debug("session {} complete", c.getId());

      try {
        barrier.await();
      } catch (InterruptedException e) {
        e.printStackTrace();
View Full Code Here

Examples of com.firefly.net.support.TcpConnection

    private final SimpleTcpClient client;
    private final CyclicBarrier barrier;

    @Override
    public void run() {
      TcpConnection c = client.connect();
      for (int i = 0; i < LOOP; i++) {
        String message = "hello world! " + c.getId();
        c.send(message, new MessageReceiveCallBack() {

          @Override
          public void messageRecieved(Session session, Object obj) {
            log.debug("rev: {}", obj);
          }
        });

      }
      c.send("quit", new MessageReceiveCallBack() {

        @Override
        public void messageRecieved(Session session, Object obj) {
          log.debug("rev: {}", obj);
          log.debug("session {} complete", session.getSessionId());
View Full Code Here

Examples of com.firefly.net.support.TcpConnection

public class SimpleTcpClientExample {
  public static void main(String[] args) {
    final SimpleTcpClient client = new SimpleTcpClient("localhost", 9900,
        new StringLineDecoder(), new StringLineEncoder());
    TcpConnection c = client.connect();
    c.send("hello client 1", new MessageReceiveCallBack() {

      @Override
      public void messageRecieved(Session session, Object obj) {
        System.out.println("con1|" + obj.toString());

      }
    });

    c.send("test client 2", new MessageReceiveCallBack() {

      @Override
      public void messageRecieved(Session session, Object obj) {
        System.out.println("con1|" + obj.toString());

      }
    });

    c.send("test client 3", new MessageReceiveCallBack() {

      @Override
      public void messageRecieved(Session session, Object obj) {
        System.out.println("con1|" + obj.toString());
      }
    });

    c.send("quit", new MessageReceiveCallBack() {

      @Override
      public void messageRecieved(Session session, Object obj) {
        System.out.println("con1|" + obj.toString());
      }
    });

    TcpConnection c2 = client.connect();
    System.out.println("con2|" + c2.send("getfile"));
    c2.close(false);

   
  }
View Full Code Here

Examples of com.firefly.net.support.TcpConnection

    for (int i = 0; i < LOOP; i++) {
      executorService.submit(new Runnable() {
        @Override
        public void run() {
          final TcpConnection c = client.connect();
          Assert.assertThat(c.isOpen(), is(true));
          log.debug("main thread {}", Thread.currentThread()
              .toString());
          Assert.assertThat((String) c.send("hello client"), is("hello client"));
          Assert.assertThat((String) c.send("hello multithread test"), is("hello multithread test"));
          Assert.assertThat((String) c.send("getfile"), is("zero copy file transfers"));
          Assert.assertThat((String) c.send("quit"), is("bye!"));
          log.debug("complete session {}", c.getId());
        }
      });

    }

    final TcpConnection c = client.connect();
    Assert.assertThat((String) c.send("hello client 2"), is("hello client 2"));
    Assert.assertThat((String) c.send("quit"), is("bye!"));
  }
View Full Code Here

Examples of com.firefly.net.support.TcpConnection

    private final CyclicBarrier barrier;
    private int id;

    @Override
    public void run() {
      TcpConnection c = tcpConnections[id];
      for (int i = 0; i < LOOP; i++) {
//        String message = "hello world! " + c.getId();
        String ret = (String) c.send(DATA);
        log.debug("rev: {}", ret);
      }
      c.close(false);
      log.debug("session {} complete", c.getId());

      try {
        barrier.await();
      } catch (InterruptedException e) {
        e.printStackTrace();
View Full Code Here

Examples of com.firefly.net.support.TcpConnection

    private final CyclicBarrier barrier;
    private int id;

    @Override
    public void run() {
      TcpConnection c = tcpConnections[id];
      for (int i = 0; i < LOOP; i++) {
//        String message = "hello world! " + c.getId();
        c.send(DATA, new MessageReceiveCallBack() {

          @Override
          public void messageRecieved(Session session, Object obj) {
            log.debug("rev: {}", obj);
          }
        });

      }
      c.send("quit", new MessageReceiveCallBack() {

        @Override
        public void messageRecieved(Session session, Object obj) {
          log.debug("rev: {}", obj);
          log.debug("session {} complete", session.getSessionId());
View Full Code Here

Examples of com.firefly.net.support.wrap.client.TcpConnection

    for (int i = 0; i < LOOP; i++) {
      executorService.submit(new Runnable() {
        @Override
        public void run() {
          TcpConnection c = null;
          try {
            c = client.connect().get();
          } catch (InterruptedException e) {
            e.printStackTrace();
          } catch (ExecutionException e) {
            e.printStackTrace();
          }
          Assert.assertThat(c.isOpen(), is(true));
          log.debug("main thread {}", Thread.currentThread()
              .toString());
          try {
            Assert.assertThat((String) c.send("hello client").get(), is("hello client"));
            Assert.assertThat((String) c.send("hello multithread test").get(), is("hello multithread test"));
            Assert.assertThat((String) c.send("getfile").get(), is("zero copy file transfers"));
            Assert.assertThat((String) c.send("quit").get(), is("bye!"));
          } catch (InterruptedException e) {
            e.printStackTrace();
          } catch (ExecutionException e) {
            e.printStackTrace();
          }
         
          log.debug("complete session {}", c.getId());
        }
      });

    }

    TcpConnection c = client.connect().get();
    try {
      Assert.assertThat((String) c.send("hello client 2").get(), is("hello client 2"));
      Assert.assertThat((String) c.send("quit").get(), is("bye!"));
    } finally {
      c.close(false);
    }
   
  }
View Full Code Here

Examples of com.firefly.net.support.wrap.client.TcpConnection

    private final SimpleTcpClient client;
    private final CyclicBarrier barrier;

    @Override
    public void run() {
      TcpConnection c = null;
      try {
        c = client.connect().get();
      } catch (InterruptedException e1) {
        e1.printStackTrace();
      } catch (ExecutionException e1) {
        e1.printStackTrace();
      }
      try {
        for (int i = 0; i < LOOP; i++) {
          String message = "hello world! " + c.getId();
          String ret = (String) c.send(message).get();
          log.debug("rev: {}", ret);
        }
      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (ExecutionException e) {
        e.printStackTrace();
      } finally {
        if (c != null)
          c.close(false);
      }
      log.debug("session {} complete", c.getId());

      try {
        barrier.await();
      } catch (InterruptedException e) {
        e.printStackTrace();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.