Telnetlib confusion

Hi all,

First off, I’m sorry if I’m posting in the wrong place. I honestly couldn’t find a better forum, but gentle nudges in the right direction are welcome.

I’m trying to work on, to keep it simple, an alternative mud client for very specific moo backends. To start, I need it to form a telnet connection and use that connection to send text strings back and forth. It will also need to be able to scan incoming text for certain strings.

The login sequence works just fine. However, while I can write text and escape out of the loop successfully, the read call just does not want to work. When I try read_all, the entire program freezes and I have to crash it from task manager.

I’ve searched all over docs and forums for a solution, but honestly can’t figure out what I’m doing wrong. I am admittedly very new at python programming. It’s very likely I’m missing something very obvious. Also, apologies if anything is formatted odd. I’m blind, so I use a screen reader to read computer text.

import telnetlib
from framework3d import window
import pygame
import time
import sys

window.initialize()
window.show_window(“Audio Mud”)
HOST = “”
user = “”
password = “”
tn = telnetlib.Telnet(HOST,1076)
tn.set_debuglevel(1) # uncomment to get debug messages
tn.read_until(b"Have a wonderful day!")
tn.write(user.encode(‘ascii’) + b"\r\n")
while 1:
print(tn.read_very_eager())
window.process_events()
time.sleep(0.005)
if window.key_pressed(pygame.K_COMMA):
tn.write(“say this is a test of sending stuffage.”.encode(‘ascii’) + b"\n")
if window.key_pressed(pygame.K_ESCAPE):
sys.exit()

Summary

This text will be hidden

Summary

This text will be hidden

yeah, apologies for the weird category things too. It wasn’t playing nice with my software.

Not a solution, but…

Add a timeout to the call to read_until and inspect what you have received. Obviously there is something else in the conversation than you expect.