python ssl socket select.select call not happy

Hi,

I can connect to a ssl server and do i/o. I am trying to move this into a loop using select for active connections. But ssl does not have a fileno and I cannot figure out how to get the parents fileno?

Here is my code:

def start_https():
global in_sock_list
global in_sock_dict
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host_name, tcp_port))
ssl_sock = socket.ssl(s)
ssl_sock.write(“”"GET /index.html HTTP/1.0

“”")
inp,outp,exc = select.select([ssl_sock],[],[],2)
print “got something”

And when I run it via a ssh shell (on a connectportx2) I get:
Traceback (most recent call last):
File “192.168.3.167:ap.py”, line 174, in ?
File “192.168.3.167:ap.py”, line 136, in start_https
TypeError: argument must be an int, or have a fileno() method.

As I understand it ssl is a wrapper around a socket. A blocking read on ssl_sock works fine, instead of the select call. How do I get it’s fileno attribute?

Thanks.

I don’t find a direct answer, but asked a few programmers and all agreed, you probably can’t use select as it want a simple file number and SSL is a complex object.

Hi Lynn,

Thanks. Now I am just carrying pointers to both the socket and the ssl socket. That works ok, but what I was hoping for was a reference in the ssl_socket to the base socket or vice versa so I only have to drag around one socket ref.