(self)
Interaction function, emulates a very dumb telnet client.
Interaction function, emulates a very dumb telnet client.
Interaction function emulates a very dumb telnet client .
def interact(self):
        """Interaction function, emulates a very dumb telnet client."""
        if sys.platform == "win32":
            self.mt_interact()
            return
        with _TelnetSelector() as selector:
            selector.register(self, selectors.EVENT_READ)
            selector.register(sys.stdin, selectors.EVENT_READ)

            while True:
                for key, events in selector.select():
                    if key.fileobj is self:
                        try:
                            text = self.read_eager()
                        except EOFError:
                            print('*** Connection closed by remote host ***')
                            return
                        if text:
                            sys.stdout.write(text.decode('ascii'))
                            sys.stdout.flush()
                    elif key.fileobj is sys.stdin:
                        line = sys.stdin.readline().encode('ascii')
                        if not line:
                            return
                        self.write(line)
def interact ( self ) : if sys . platform == "win32" : self . mt_interact ( ) return with _TelnetSelector ( ) as selector : selector . register ( self , selectors . EVENT_READ ) selector . register ( sys . stdin , selectors . EVENT_READ ) while True : for key , events in selector . select ( ) : if key . fileobj is self : try : text = self . read_eager ( ) except EOFError : print ( '*** Connection closed by remote host ***' ) return if text : sys . stdout . write ( text . decode ( 'ascii' ) ) sys . stdout . flush ( ) elif key . fileobj is sys . stdin : line = sys . stdin . readline ( ) . encode ( 'ascii' ) if not line : return self . write ( line )