@Override
	public byte[] write(DataOutputStream out, PassthroughConnection ptc, KillableThread thread, boolean serverToClient) {

		if((length = lengthUnit.getValue()) < 0) {
			lengthUnit.setValue(length);
		}
		length = lengthUnit.write(out, ptc, thread, serverToClient);
		if(length == null) {
			return null;
		}

		incrementCounter(serverToClient, Math.abs(length), ptc);
		
		while(true) {
			try {
				out.write(value, 0, Math.abs(length));
				out.flush();
			} catch ( SocketTimeoutException toe ) {
				if(timedOut(thread)) {
					continue;
				}
				return null;
			} catch (IOException e) {
				return null;
			}

			super.timeout = 0;

			return value;
		}

	}