This is our old Q&A Site. Please post any new questions and answers at

Hello. I am using a Python3.3 script that uses a telnet connection from telnetlib library.

Now, I am using the write(command) and read() functions of this connection.

So, after wiresharking this simple code:

import telnetlib
import sys
def func1(IP,user,passw):
    return t

def func2(t,command):

for i in range(6):
   func2(t, "message "+str(i))

I saw a weird behavior on Wireshark. After submitting the username and password, it send to the server a packet which contains only 2 messages out of six (within the 'for loop'), and the next packet is also from my computer, resetting the telnet conection!

By adding a line to func2:

def func2(t,command):
    t.read_eager()   #The new line

Somehow it works fine.

Now, it should not be like that. If I am using the write(command) 10 times one after each other, not the way I used here, It works fine without any need of read().

Any idea?

The last two packets:

  no.    time       source  destination  protocol  info

1501    11.754366   A.B.C.A *.*.*.113   TELNET  Telnet Data ...

1502    11.760757   A.B.C.A *.*.*.113   TCP esimport > telnet [RST, ACK] Seq=40 Ack=7 Win=0 Len=0

asked 30 Oct '13, 04:30

itay_user's gravatar image

accept rate: 0%

edited 30 Oct '13, 04:58

this sounds more like a question for the developer of telnetlib (and/or a Python network programming forum) than for the Wireshark community, especially as did not provide a capture file !?!

Anyway: Can you post a capture file somewhere (google docs, dropbox, Maybe we can see something that helps you to debug your code.

permanent link

answered 30 Oct '13, 06:02

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
accept rate: 15%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 30 Oct '13, 04:30

question was seen: 1,725 times

last updated: 30 Oct '13, 07:20

p​o​w​e​r​e​d by O​S​Q​A