public static void main(String argv[]) throws Exception {

		PORT = Integer.parseInt(argv[0]);
		FILENAME = argv[1];
		WINDOW = Integer.parseInt(argv[2]);
		serverSocket = new DatagramSocket(PORT);

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		boolean eof = false;

		ArrayList<byte[]> packet_buffer = new ArrayList<byte[]>();
		PacketReceptor receptor = new PacketReceptor(packet_buffer, 0, WINDOW);
		Thread receiver = new Thread(receptor);
		receiver.start();

		/**
		 * Checks to the write buffer in the receptor thread can be managed
		 * through the introduction of a thread sleep within this loop
		 */
		ArrayList<byte[]> write_to_baos = new ArrayList<byte[]>();
		do {

			/**
			 * Pop the write buffer from the receptor thread so that the main
			 * thread can write the data to memory
			 */

			write_to_baos = receptor.popWriteBuffer();

			for (byte[] x : write_to_baos) {
				//IF WINDOW IS LARGER THAN NUM OF EOF
				if(Utilities.isEOF(x)){
					if(receptor.getSOW() > Utilities.getPacketNum(x)){
						eof = true;
					}
				}
				baos.write(Utilities.getData(x));
			}
			
		} while (eof == false);

		receptor.stop();

		FileOutputStream writeToFile = new FileOutputStream(FILENAME);
		System.out.println("Transmission complete! Writing to file...");
		writeToFile.write(baos.toByteArray());
	}