package com.peterhi.net3;
import java.net.DatagramPacket;
import java.net.SocketAddress;
import com.peterhi.net3.Local.Listener;
public class Server {
public static void main(String[] args) throws Exception {
Local local = new Local(22222);
local.getSocket().setSoTimeout(10);
local.addListener(new Listener() {
@Override
public void received(SocketAddress address, byte[] data) {
System.out.println("Received " + new String(data) + " from " + address);
}
});
while (local.getSocket().isBound()) {
DatagramPacket packet = local.receive();
if (packet == null) {
continue;
}
local.process(packet);
}
}
}