import java.io.*;
import java.net.*;

public class Client {
    public static void main(String args[]) {

	Socket serverSocket;
	DataInputStream inputStream;
	PrintStream outputStream;

	int PortNumber=9999;

	try {
	    System.err.println("Connecting on server on localhost, port 9999.");
	    serverSocket = new Socket("localhost", PortNumber);
	    inputStream = new DataInputStream(serverSocket.getInputStream());
	    outputStream = new PrintStream(serverSocket.getOutputStream());
	}
	catch (IOException e) {
	    System.out.println(e);
	    return;
	}

	String line;
	try {
	    line = inputStream.readLine();
	}
	catch (IOException e) {
	    System.err.println(e);
	    return;
	}
	System.err.println("Server said: "+line);

	outputStream.println("hello");
	try {
	    line = inputStream.readLine();
	}
	catch (IOException e) {
	    System.err.println(e);
	    return;
	}
	System.err.println("Server answered: "+line);

	
	outputStream.close();
    }
}
