public int consumeIncoming(short[] incoming, TelnetClient client) {
		int read = 0;
		if (incoming[0] == client.IAC &&
			incoming[1] == client.SB &&
			incoming[2] == getCode() &&
			incoming[3] == IS) 
		{
			int iacIndex = 0;
			// from [4] to the next IAC is the regime to be supported.
			for (int i = 4; i < incoming.length; i++) {
				if (incoming[i] == client.IAC) {
					iacIndex = i;
					break;
				}
			}
			
			// If we didn't find an IAC, we don't have a full data frame.
			if (iacIndex == 0) {
				read = 0;
			} else {
				short[] regime = new short[(iacIndex - 1) - 4];
				System.arraycopy(incoming, 4, regime, 0, regime.length);
				
				// Convert to string, without getting encoding exceptions.
				StringBuffer sb = new StringBuffer();
				for (short b : regime) {
					sb.append((char)b);
				}
				String regimeName = sb.toString();
				
				// If we got something other than an empty string back as 
				// part of our Regime negotiation, then we need to consider
				// everything coming in as 3270 binary data.
				if (!regimeName.equals("")) {
					binaryHandler.setEnabled(true, client);
					eor.setEnabled(true, client);
				} else {
					binaryHandler.setEnabled(false, client);
					eor.setEnabled(false, client);
				}
				
				read = 4 + regime.length + 2;
			}
		}
		return read;
	}