int port = DEFAULT_PORT;
try {
port = Integer.parseInt(args[0]);
}
catch (Exception ex) {
}
try {
DatagramChannel channel = DatagramChannel.open();
DatagramSocket socket = channel.socket();
SocketAddress address = new InetSocketAddress(port);
socket.bind(address);
ByteBuffer buffer = ByteBuffer.allocateDirect(MAX_PACKET_SIZE);
while (true) {
SocketAddress client = channel.receive(buffer);
buffer.flip();
channel.send(buffer, client);
buffer.clear();
} // end while
} // end try
catch (IOException ex) {
System.err.println(ex);
} // end catch