How do I check if Telnet session is open?

Mudcat mnations at gmail.com
Wed Oct 20 18:28:36 EDT 2004


Let me narrow the focus a little since I've found out how this is
usually done. I'm attempting to solve the problem using select. However
I can't get the select function to block until something's available.
Here is my code. I am running on windows.

>>> conn = telnetlib.Telnet("10.10.10.89", "3083")
>>> conn2 = telnetlib.Telnet("10.10.10.89", "3083")
>>> sock = conn.get_socket()
>>> sock2= conn2.get_socket()
>>> sock.setblocking(1)
>>> sock2.setblocking(1)
>>> w, r, e = select.select([], [sock, sock2], [] )

Pretty simple really. I'm blocking on the sockets which should block on
the select call. However it never blocks. The call returns immediately
spitting back out both my sockets which have nothing in them. When I do
a socket recv on both, they block because they contain no info. The
select should have never returned in the first place.
Anyone know what I'm doing wrong?




More information about the Python-list mailing list