public synchronized String receive(boolean forgive, int timeout)
			throws SQMLEException, SQMLETimeOutException {

		byte[] retval = new byte[0];
		int totalWaitTime = 0;
		try {
			while (socketInput.available() == 0) {
				// waiting
				try {
					Thread.sleep(this.loopTime);
					totalWaitTime = totalWaitTime + this.loopTime;
					if (totalWaitTime >= timeout && !forgive) {
						// no answer within time period, close everything
						this.socketInput.close();
						this.socketOutput.close();
						this.socket.close();
						throw new SQMLEException(
								"Connection closed or wrong password");
					} else if (totalWaitTime >= timeout && forgive) {
						// if timeout expired return empty string, the server
						// did not say anything
						throw new SQMLETimeOutException(
								"Did not receive a reply fast enough. Please adjust replyTimout?");
					}
				} catch (InterruptedException ex) {
					Thread.currentThread().interrupt();
				}
			}
		} catch (IOException e) {
			throw new SQMLEException(e);
		}
		try {
			retval = new byte[socketInput.available()];
		} catch (IOException e) {
			throw new SQMLEException(e);
		}
		try {
			socketInput.read(retval);
		} catch (IOException e) {
			throw new SQMLEException(e);
		}

		// convert to String
		String response = new String(retval);
		return (response);
	}