def is_alive(self):
null = chr(<NUM_LIT:0>)<EOL>if self.device is None:<EOL><INDENT>return {"<STR_LIT>": False}<EOL><DEDENT>if self.transport == "<STR_LIT>":<EOL><INDENT>try:<EOL><INDENT>self.device.write_channel(telnetlib.IAC + telnetlib.NOP)<EOL>return {"<STR_LIT>": True}<EOL><DEDENT>except UnicodeDecodeError:<EOL><INDENT>return {"<STR_LIT>": True}<EOL><DEDENT>except AttributeError:<EOL><INDENT>return {"<STR_LIT>": False}<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>self.device.write_channel(null)<EOL>return {"<STR_LIT>": self.device.remote_conn.transport.is_active()}<EOL><DEDENT>except (socket.error, EOFError):<EOL><INDENT>return {"<STR_LIT>": False}<EOL><DEDENT><DEDENT>return {"<STR_LIT>": False}<EOL>
Returns a flag with the state of the connection.