M2Crypto: select() behaves weird on SSL socket
donn at drizzle.com
Tue Jun 11 04:34:58 CEST 2002
Quoth Irmen de Jong <irmen at NOSPAMREMOVETHISxs4all.nl>:
| The manual page of select(2) says:
| "select waits for a number of file descriptors to change status.
| Three independent sets of descriptors are watched. Those
| listed in readfds will be watched to see if characters
| become available for reading (more precisely, to see if a
| read will not block - in particular, a file descriptor is
| also ready on end-of-file), those in writefds will be
| watched to see if a write will not block, and those in
| exceptfds will be watched for exceptions."
| The way I interpret this is that -buffering or not- select must
| return a FD if there is more data available. In my case, the SSL
| socket indeed has more data available, and a recv() on the socket
| will not block. I therefore think that either M2Crypto or OpenSSL
| is doing the wrong thing because select() doesn't behave as it should?
| The recv() may read from a buffer, I don't care, but it doesn't
| block on my next call and thus I expect select() to return the socket
| as being ready for reading... am I wrong here?
Wrong, I'd say. SSL's buffer, like the file object's stdio buffer,
is user process storage. From select's point of view (the low level
device) you have already read that data, and it doesn't know or care
what you did with it.
I see my reply earlier today followed up a separate thread, after
you posted your initial question twice. If you haven't seen it,
a hint: SSL_pending(self->ssl.) (I don't know much more than that,
Donn Cave, donn at drizzle.com
More information about the Python-list