public void negotiateTerminalType(byte opcode) throws IOException {
		switch (opcode) {
		case DO:
			// DO TERMINAL-TYPE
			System.out.println();
			synchronized (out) {
				out.write(IAC);
				out.write(WILL);
				out.write(TERMINAL_TYPE);
				out.flush();
				System.out.println("SEND>IAC WILL TERMINAL_TYPE");
			}
			break;

		case SB:
			// SB TERMINAL-TYPE
			int data = in.read();
			if (data == -1) {
				throw new EOFException();
			}
			switch ((byte) data) {
			case SEND:
				expect(IAC);
				expect(SE);
				System.out.println("SEND IAC SE");

				synchronized (out) {
					out.write(IAC);
					out.write(SB);
					out.write(TERMINAL_TYPE);
					out.write(IS);
					out.write(terminalType.getBytes());
					out.write(IAC);
					out.write(SE);
					out.flush();
					System.out.println("SEND>IAC SB TERMINAL-TYPE IS " + terminalType + " IAC SE");
				}
				break;

			default:
//				throw new TelnetException("Unknown IAC SB TERMINAL-TYPE " + data);
			}
			break;

		default:
			System.out.println(opcode + " TERMINAL-TYPE unhandled");
		}
	}