telnetlib close not closing sockets

Mike Monaghan junkmail at chipworks.net
Thu Sep 23 15:30:10 EDT 2004


Yannick,

The parenthesis after the tn.close() did the trick.  I know I've made
that mistake somewhere else.  Telnetlib's documentation even clearly
says .close() and I bet they mean the () is required.  Thank you!!!

As for read_until, I'm not reaching timeout there.  I am however
setting a timeout in the statement like so:

  print tn.read_until("\n>",5)

Maybe that change is  making it work for me.  Did you set a timeout
value when you were testing?

I do have a problem with an expect, but I'm 99% sure a control
character in the stream is missing from my expect statement because
some of the strings are being detected.  I'm going to play with it
again tonight.

I have to say I'm much impressed with the python language,
documentation, and community.  It will take a while to understand some
of the doc as they are written in a very technical manner.  I
personally think its great because most software efforts are plagued
by poor documentation.  So far all my problems have been my own.

Thanks again for your help!

Mike

Yannick Turgeon <nobody at nowhere.com> wrote in message news:<nwn4d.19601$pA.1328640 at news20.bellglobal.com>...
> Hello Mike,
> 
> Your subject remembered me some hard time using telnetlib on Windows. Oh God
> I searched for answers!:o) I would be very happy to prevent you this. To
> verify if you have the same problem, Could you tell me if you always reach
> the timeout (5 secs) before your read_until() return? 
> 
> For your current problem. Did you try with parenthesis after "close": 
> tn.close()
> 
> I hope it was just that! 
> 
> Yannick
> 
> Mike Monaghan wrote:
> > HOST = "fred"
> > tn = telnetlib.Telnet(HOST)
> > tn.write("DEMO\n")
> > print tn.read_until("\n>",5)
> > tn.write("OFF\n")
> > print tn.read_until("Logon Please:",5)
> > print tn.read_until("make sure socket queue is empty the hard way",5)
> > tn.close
> > 
> > I've tried several options to accomplish this, but for whatever reason
> > the socket remains open until I exit python.



More information about the Python-list mailing list