How to avoid blocking in socket.ssl() ?

Claudio cls at xpnet.com.br
Thu Oct 16 14:12:22 EDT 2003


Hi,

I am trying to incorporate support for SSL in an
existing Python TCP/IP client program so it could
connect to an SSL server. Both the client and server
uses a proprietary protocol.

This client program uses asyncore because it could not
block in any way and it does not use threads.
After the client connects to the server, 
I use 'socket.ssl(...)' to initiate the SSL connection.
If the server is ready to accept SSL connections, 
'socket.ssl()' returns quick enough, but if the
server does not accept SSL connections 
socket.ssl() blocks for a long time...
(I waited several minutes and it didn't return).
Is there anyway to avoid blocking in socket.ssl()
and return an error in this situation ?

I am using the native support of SSL in Python 2.3.2
using Linux 2.4.20 but the client will have to
run in Windows also.

Regards,
Claudio L. S.




More information about the Python-list mailing list