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