Package com.peterhi.working

Source Code of com.peterhi.working.Server

package com.peterhi.working;

import java.io.InputStream;
import java.net.DatagramSocket;

import com.peterhi.working.EndpointImpl;
import com.peterhi.working.Event;
import com.peterhi.working.Listener;

public class Server {

  public static void main(String[] args) throws Exception {
    EndpointImpl endpoint = new EndpointImpl(new DatagramSocket(22222));
    endpoint.addListener(new Listener() {
      @Override
      public void update(Event event) {
        try {
          InputStream stream = event.getInputStream();
         
          if (stream.available() == 0) {
            System.out.println();
          }
         
          System.out.println("Received " + stream.available() + " bytes of " +
            (event.isReliable() ? "reliable" : "unreliable") + " data.");
        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }
    });
   
    endpoint.run();
  }
 
}
TOP

Related Classes of com.peterhi.working.Server

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.