/* GrnvsTcpClient.java */

import java.net.*;
import java.io.*;

public class GrnvsTcpClient {
	private static BufferedReader in;
	private static BufferedWriter out;
	private static Socket socket;

	public static void main(String[] args) {
		if (args.length != 2) {
			System.err.println("Usage: java GrnvsTcpClient <host> <port>");
			System.exit(1);
		}
		// The communication will get handled by the communicate-method...
		communicate(args[0], Integer.parseInt(args[1]));
	}

	private static void communicate(String host, int port) {
		try {
			/*
			 * Create the socket and the according buffers...
			 */

			// to do...
			/*
			 * Implement the protocol... Send only ONE Name per session, so if
			 * your team has two members run the code twice, once with each of
			 * your names... Don't forget to check if the submission
			 * succeeded...
			 */
			System.out.println(in.readLine()); // Greetings
			say("HELLO"); // say HELLO

			// to do...

		} catch (IOException e) {
			System.err.println(e.toString());
			System.exit(1);
		}

	}

	private static void say(String msg) {
		/*
		 * We have to do a lot of sending to the Server so we summed this up
		 * here...
		 */
		try {
			System.out.println("--> " + msg); // Output locally for debug...
			out.write(msg + "\r\n"); // Send to the receiving server
			                         // socket...
			out.flush(); // Send data out now and do not wait until the send
			             // buffer is full...
		} catch (IOException e) {
			System.err.println(e.toString());
		}
	}
}