Package ch.usi.dslab.bezerra.netwrapper

Examples of ch.usi.dslab.bezerra.netwrapper.Message


     
      // skip the buffer length parameter
      buffer.position(buffer.position() + 4);
     
      Input in = new Input(new ByteBufferInputStream(buffer));
      Message msg = (Message) kryo.readClassAndObject(in);
      in.close();
      msg.rewind();
      return msg;
   }
View Full Code Here


import 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

public class SimpleTcpClientSenderReceiver {

   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);

      TCPMessage msg = receiver.receive();
      String reply = (String) msg.getContents().getItem(0);
      System.out.println("Reply received: " + reply);

      Message message2 = new Message(new String("second message from client"));

      sender.send(message2, serverConnection);

      TCPMessage msg2 = receiver.receive();
      String reply2 = (String) (msg2.getContents().getItem(0));
View Full Code Here

     
      while(!Thread.interrupted()) {
         TCPMessage msg = receiver.receive();
         String recvdMessage = (String) msg.getContents().getItem(0);
         System.out.println("Received message: " + recvdMessage);
         Message ack = new Message(new String("Ack for message \"" + recvdMessage + "\""));
         sender.send(ack, msg.getConnection());
      }
   }
View Full Code Here

TOP

Related Classes of ch.usi.dslab.bezerra.netwrapper.Message

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.