private static void retrieveFiles(OutputStream out, InputStream in, int page) throws IOException, RuntimeException{
		System.out.println("Contacting Server...");
		// (view files req c->s) [header | page (4)]
		// (initial response) [header | num files to expect | total num (4)]
		// (list of available clients s->c) [header | size(8) | num_peers(4) | id(4) | name(?)]xNum files
		
		buf = Utility.addHeader(Constants.VIEW_REQ, 4, id);
		buf.putInt(Constants.HEADER_LEN, page);
		out.write(buf.array());
		out.flush();
		
		// read response
		if ((buf=Utility.readIn(in, Constants.HEADER_LEN + 8)) == null)
			throw new IOException("read failed.");
		
		// header?
		if (!Utility.checkHeader(buf, Constants.VIEW_REQ, 8, id)){
			throw new RuntimeException("Malformed header from Server detected!");
		}
		int num_files = buf.getInt(Constants.HEADER_LEN);
		num_files_on_server = buf.getInt(Constants.HEADER_LEN + 4);
		System.out.println("Retrieved " + num_files +"/" +num_files_on_server+
				" files from server (page #"+page+" of " +(num_files_on_server / Constants.PAGE_SIZE + 1)+"):");
		
		//Receive files from server
		retrieved_files = new HashMap<Integer, Integer>();
		retrieved_file_sizes = new HashMap<Integer, Long>();
		int flag, payload_len, buf_id, num_peers;
		long file_size;
		String name;
		for (int i=0; i < num_files; i++){
			if ((buf=Utility.readIn(in, Constants.HEADER_LEN)) == null)
				throw new IOException("read failed.");
			flag = buf.getInt(0);
			payload_len = buf.getInt(4);
			buf_id = buf.getInt(8);
			// Check correctness of header
			if (id != buf_id || flag != Constants.VIEW_REQ)
				throw new RuntimeException("Malformed header from Server detected!");
			// read payload
			if ((buf = Utility.readIn(in, Utility.getPaddedLength(payload_len))) == null)
					throw new IOException("read failed.");
			file_size = buf.getLong(0);
			num_peers = buf.getInt(8);
			buf_id = buf.getInt(12);
			name = getNameFromBuf(16, buf);
			if (name.length() == 0)
				throw new RuntimeException(
						"Connection - FAILURE! (filename not correctly uploaded)");
			// Display files (one per line)
			System.out.println((i+1) + ". "+name +", ("+file_size+" bytes), " +num_peers+" peers.");
			retrieved_files.put(i+1, buf_id);
			retrieved_file_sizes.put(buf_id, file_size);
		}
		System.out.println("Done");
	}