import java.io.*; import java.net.*; import java.util.*; import java.nio.*; import java.nio.channels.*; import java.nio.charset.*; public class QuoteClient { public static void main(String[] args) throws IOException { if (args.length != 1) { System.out.println("Usage: java QuoteClient "); return; } FloatBuffer fb = FloatBuffer.allocate(256); System.out.println("fb class = " + fb.getClass().getName()); DatagramChannel dChannel = DatagramChannel.open(); ByteBuffer bBuf = ByteBuffer.allocateDirect(256); InetAddress address = InetAddress.getByName(args[0]); InetSocketAddress sockAddr = new InetSocketAddress(address, 4445); dChannel.send(bBuf, sockAddr); bBuf.clear(); dChannel.receive(bBuf); bBuf.flip(); Charset charset = Charset.forName("ISO-8859-1"); CharBuffer cBuf = charset.decode(bBuf); System.out.println("Quote of the Moment: " + cBuf.toString()); dChannel.close(); } }