DatagramPacket incoming;
int port;
int len;
try {
port = Integer.parseInt(args[0]);
}
catch (Exception e) {
port = defaultPort;
}
try {
len = Integer.parseInt(args[1]);
}
catch (Exception e) {
len = defaultBufferLength;
}
try {
DatagramSocket ds = new DatagramSocket(port);
byte[] buffer = new byte[len];
incoming = new DatagramPacket(buffer, buffer.length);
while (true) {
try {
ds.receive(incoming);
respond(ds, incoming);
}
catch (IOException e) {
System.err.println(e);
}
} // end while
} // end try
catch (SocketException se) {
System.err.println(se);
} // end catch