//TestTCPClient.java

import java.io.*;
import java.net.*;
import krb5.lib.*;

class TestTCPClient {

	public static void main(String[] args) throws IOException, InterruptedException {
		int port = 7777;
		int i = 0;
		krb5.lib.TCPClient client = new krb5.lib.TCPClient(InetAddress.getLocalHost(), port);
		boolean loop = true;
		do {
			try {

				String request = "request" + new Integer(++i).toString();
				byte[] out = new byte[request.length()];
				request.getBytes(0, request.length(), out, 0);
				System.out.println(new String(out, 0));
				client.send(out);
				byte[] in = client.receive();
				System.out.println(new String(in, 0));
				Thread.currentThread().sleep(1000);
			}
			catch (IOException e) {
				e.printStackTrace();
				loop = false;
			}
		}
		while(loop);
		client.close();
	}

}
