import java.io.*;
import java.net.*;
import java.util.*;

public class QuoteClient {
    final static short port = 4445;

    public static void main(String[] args) throws IOException {
        String s;
        final short port = 4445;
        if (args.length != 1) {
//             System.out.println("Usage: java QuoteClient <hostname>");
//             return;
               s = "localhost";
        } else {
        	   s = args[0];
        }

            // get a datagram socket
        DatagramSocket socket = new DatagramSocket();

            // send request
        byte[] buf = new byte[256];
        InetAddress address = InetAddress.getByName(s);
        DatagramPacket packet = new DatagramPacket(buf, buf.length, address, port);
        socket.send(packet);
    
            // get response
        packet = new DatagramPacket(buf, buf.length);
        socket.receive(packet);

	    // display response
        String received = new String(packet.getData());
        System.out.println("Quote of the Moment: " + received);
    
        socket.close();
    }
}
