import java.io.OutputStream;
import java.net.Socket;

public class tcpclienttemplate {

	public static void main(String[] args) {
		try {
			if(args.length != 2) throw new IllegalArgumentException("Need arguments - host and port");
			String host = args[0];
			int port = Integer.parseInt(args[1]);

			/* TODO: */
			/*  - połącz się z siecią */

			new Thread(() -> {
				try {
					while (true) {
						byte[] data = new byte[256];
						int count = System.in.read(data);
						/* TODO: */
						/*  - wyślij dane przez sieć */
					}
				} catch (Throwable e) {
					System.out.print(e.getLocalizedMessage());
					System.out.println();
					System.exit(0);
				}
			}).start();

			while (true) {
				Thread.sleep(Long.MAX_VALUE);
				byte[] data = new byte[256];
				/* TODO: */
				/*  - wyrzuć sleepa */
				/*  - odbierz dane z sieci */
				System.out.write(data);
				System.out.flush();
			}
		} catch (Throwable e) {
			System.out.print(e.getLocalizedMessage());
			System.out.println();
		}
		System.exit(0);
	}
}
