public static void main(String[] args) throws UnknownHostException {

		if(args.length != 5) {
			printUsage();
		}
		
		short srcPort = Short.parseShort(args[0]);
		short desPort = Short.parseShort(args[1]);
		int windowSize = Integer.parseInt(args[2]);
		int timeout = Integer.parseInt(args[3]);
		String filename = args[4];
		inputCheck(srcPort, desPort, timeout);

		InetAddress addr = InetAddress.getLocalHost();
		String srcIP = addr.getHostAddress().toString();
		String desIP = srcIP;
		
		System.out.println("Starting 740Ftp client ...");

		try {
			TTPService ttp = new TTPService((short) srcPort, windowSize, timeout);
			Object data = filename;
			System.out.println("Requesting file: " + filename);
			
			ttp.connect(srcIP, desIP, srcPort, desPort);
			ttp.send(data);
			Object file = ttp.receive();
			
			File localFile = new File("Received_" + filename);
	        if(!localFile.exists()) {
	        	 localFile.createNewFile();
	        }
	        FileOutputStream out = new FileOutputStream(localFile);
	        out.write(file.toString().getBytes());
	        out.close();
			System.out.println("Received file from server, saved as: Received_" + filename);
			
			ttp.close();

		} catch (SocketException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

	}