Package ch.usi.dslab.bezerra.netwrapper.examples

Source Code of ch.usi.dslab.bezerra.netwrapper.examples.SimpleTcpServer

package ch.usi.dslab.bezerra.netwrapper.examples;

import ch.usi.dslab.bezerra.netwrapper.Message;
import ch.usi.dslab.bezerra.netwrapper.tcp.TCPMessage;
import ch.usi.dslab.bezerra.netwrapper.tcp.TCPReceiver;
import ch.usi.dslab.bezerra.netwrapper.tcp.TCPSender;

public class SimpleTcpServer {
  
   public static void main(String[] args) {
      TCPReceiver receiver = new TCPReceiver(50000);
      TCPSender   sender   = new TCPSender  ();
     
      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());
      }
   }

}
TOP

Related Classes of ch.usi.dslab.bezerra.netwrapper.examples.SimpleTcpServer

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.