code: def _write_channel(self, out_data):
          
          if self.protocol == "ssh":
              self.remote_conn.sendall(write_bytes(out_data, encoding=self.encoding))
          elif self.protocol == "telnet":
              self.remote_conn.write(write_bytes(out_data, encoding=self.encoding))
          elif self.protocol == "serial":
              self.remote_conn.write(write_bytes(out_data, encoding=self.encoding))
              self.remote_conn.flush()
          else:
              raise ValueError("Invalid protocol specified")
          try:
              log.debug(
                  "write_channel: {}".format(
                      write_bytes(out_data, encoding=self.encoding)
                  )
              )
              if self._session_log_fin or self.session_log_record_writes:
                  self._write_session_log(out_data)
          except UnicodeDecodeError:
              # Don't log non-ASCII characters; this is null characters and telnet IAC (PY2)
              pass
docs: Generic handler that will write to both SSH and telnet channel.
  
          :param out_data: data to be written to the channel
          :type out_data: str (can be either unicode/byte string)