/** * * Writes a byte to the stream. * * <p> * * @param ch The byte to write. * @exception IOException If an error occurs while writing to the underlying stream. * */ @Override public void write(int ch) throws IOException { synchronized (__client) { ch &= 0xff; if (__client._requestedWont(TelnetOption.BINARY)) // i.e. ASCII { if (__lastWasCR) { if (__convertCRtoCRLF) { __client._sendByte('\n'); if (ch == '\n') // i.e. was CRLF anyway { __lastWasCR = false; return; } } // __convertCRtoCRLF else if (ch != '\n') { __client._sendByte('\0'); // RFC854 requires CR NUL for bare CR } } __lastWasCR = false; switch (ch) { case '\r': __client._sendByte('\r'); __lastWasCR = true; break; case TelnetCommand.IAC: __client._sendByte(TelnetCommand.IAC); __client._sendByte(TelnetCommand.IAC); break; default: __client._sendByte(ch); break; } } // end ASCII else if (ch == TelnetCommand.IAC) { __client._sendByte(ch); __client._sendByte(TelnetCommand.IAC); } else { __client._sendByte(ch); } } }
/** * Closes the stream. ** */ @Override public void close() throws IOException { __client._closeOutputStream(); }
/** * Flushes the stream. ** */ @Override public void flush() throws IOException { __client._flushOutputStream(); }