code: def interact(self, insock=sys.stdin, outsock=sys.stdout):
          
          self._print_header('======== Beginning interactive session ========')
  
          if hasattr(outsock, 'buffer'):
              outsock = outsock.buffer    # pylint: disable=no-member
  
          self.timed_out = False
  
          save_verbose = self.verbose
          self.verbose = 0
          try:
              if self.buf:
                  outsock.write(self.buf)
                  outsock.flush()
                  self.buf = b''
  
              while True:
                  readable_socks = select(self.sock, insock)
                  for readable in readable_socks:
                      if readable is insock:
                          data = os.read(insock.fileno(), 4096)
                          self.send(data)
                          if not data:
                              raise NetcatError
                      else:
                          data = self.recv(timeout=None)
                          outsock.write(data)
                          outsock.flush()
                          if not data:
                              raise NetcatError
          except KeyboardInterrupt:
              self.verbose = save_verbose
              self._print_header('\n======== Connection interrupted! ========')
              raise
          except (socket.error, NetcatError):
              self.verbose = save_verbose
              self._print_header('\n======== Connection dropped! ========')
          finally:
              self.verbose = save_verbose
docs: Connects the socket to the terminal for user interaction.
          Alternate input and output files may be specified.
  
          This method cannot be used with a timeout.
  
          Aliases: interactive, interaction