in tester/src/main/java/org/apache/james/jspf/tester/UDPListener.java [121:145]
public void run() {
try {
DatagramSocket sock = new DatagramSocket(port, addr);
final short udpLength = 512;
byte[] in = new byte[udpLength];
DatagramPacket indp = new DatagramPacket(in, in.length);
while (true) {
indp.setLength(in.length);
try {
sock.receive(indp);
} catch (InterruptedIOException e) {
continue;
}
byte[] local = new byte[indp.getLength()];
System.arraycopy(in, 0, local, 0, indp.getLength());
Runnable runnable = new UDPResponder(sock, indp.getAddress(), indp.getPort(), local, responseGenerator);
new Thread(runnable).start();
}
} catch (IOException e) {
System.out.println("UDPListener(" + addr.getHostAddress() + "#" + port + "): "
+ e);
}
}