public int read(byte[] b, int off, int len, int delim) throws IOException, DelimiterNotFoundException {
		int bytesRead = -1;
		boolean waited = false;
		if(!connected)
			return bytesRead;
		// we are reading from the pause file
		if(pausing && pause != null) {
			bytesRead = super.read(b, off, len, delim);
			// start from the beginning when end is reached
			if(bytesRead == -1) {
				setInputStream(new FileInputStream(pause));
				return read(b, off, len, delim);
			}
		}
		// we are pausing and waiting for server input
		if(pausing && pause == null) {
			waited = true;
			synchronized(this) {
				try {
					wait();
				}
				catch(InterruptedException e) {
					// nah
				}
			}
		}
		// we are reading from the server input
		if(!pausing || waited) {
			try {
				bytesRead = super.read(b, off, len, delim);
			}
			catch(IOException e) {
				// switch to pause mode
			}
			if(bytesRead == -1) {
				pausing = true;
				return read(b, off, len, delim);
			}
		}
		idle = false;
		return bytesRead;
	}