telnet 'connection reset by peer'

Donnal Walter donnal at donnal.net
Mon Aug 23 13:39:47 EDT 2004


Eddie Corns wrote:

> 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.

Telnet(nnn.nn.nnn.nnn,23): recv 
'\xff\xfb\x03\xff\xfd\x03\xff\xfb\x01\xff\xfd\x1
7\xff\xfb\x00\xff\xfd\x00'
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 3
Telnet(nnn.nn.nnn.nnn,23): IAC DO 3
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 1
Telnet(nnn.nn.nnn.nnn,23): IAC DO 23
Telnet(nnn.nn.nnn.nnn,23): IAC WILL 0
Telnet(nnn.nn.nnn.nnn,23): IAC DO 0
Traceback (most recent call last):
   File "C:\Python23\Lib\site-packages\mindwrapper\test\telnet.py", line 
5, 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')

Thank you for the suggestion. Can you help me interpret the feedback?

> Does it happen instantly or is something timing out?

No, it always happens instantly.

Thanks.

Donnal Walter
Arkansas Children's Hospital





More information about the Python-list mailing list