telnet 'connection reset by peer'

Eddie Corns eddie at holyrood.ed.ac.uk
Mon Aug 23 13:22:50 EDT 2004


Donnal Walter <donnal at donnal.net> writes:

>On Windows XP I am able to connect to a remote telnet server from the 
>command prompt using:

>telnet nnn.nnn.nnn.nnn 23

>where nnn.nnn.nnn.nnn is the IP address of the host. But using 
>telnetlib, this code returns the traceback that follows:

>import telnetlib
>host = 'nnn.nnn.nnn.nnn'
>tn = telnetlib.Telnet(host, 23)
>tn.read_until("Enter device name?")


>Traceback (most recent call last):
>   File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line 
>4, in ?
>     tn.read_until("Enter device name?")
>   File "C:\Python23\lib\telnetlib.py", line 316, in read_until
>     self.fill_rawq()
>   File "C:\Python23\lib\telnetlib.py", line 521, in fill_rawq
>     buf = self.sock.recv(50)
>socket.error: (10054, 'Connection reset by peer')

>Is there some parameter that I need to set in order to connect using the 
>telnetlib client? Thanks.

No, that should work, to a reasonably conforming telnet server.  Try doing
tn.set_debuglevel(2) before the read_until() to see what's coming back.

Does it happen instantly or is something timing out?

Eddie





More information about the Python-list mailing list