telnetlib close not closing sockets
Mike Monaghan
junkmail at chipworks.net
Wed Sep 22 18:37:29 EDT 2004
I'm rather new to python but a long time programmer. I think I've
covered my bases so I hope this isn't somthing obvious.
I'm running ActiveState PythonWin 2.3.2 (#49, Nov 13 2003, 10:34:54)
[MSC v.1200 32 bit (Intel)] on win32.
I have several processes that are polling a telnet server on a regular
basis. I'm using telnetlib for this. When I issue the .close method
the connection is not closed (no TCP FIN is sent to the server).
import getpass
import sys
import telnetlib
import smtplib
import time
import os
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. Since I'm polling in a
loop I'd prefer not to exit python. I must close the tcp connection
after each pass or I'll consume server licenses.
Any of you pythoneers have a clue where I should be looking? Is this
a bug in telnetlib, the socket handlers, or the windows port? Am I
missing something obvious? Telnetlib looks like it is making the
right close calls.
Thanks,
Mike
A python newb
More information about the Python-list
mailing list