public boolean fillBuffer(int min) {
		if (closed)
			return false;
		assert buffer.length >= min;
		int read = 0;
		try {
			while (read != -1 && bufferLimit < min) {
				read = connection.getInputStream().read(buffer, bufferLimit, buffer.length - bufferLimit);
				bufferLimit += read;
			}
		} catch (IOException e) {
			close(e.getMessage());
			return false;
		}

		if (read == -1) {
			close("EOF reached.");
			return false;
		}
		assert bufferLimit >= min;
		return true;
	}