如何接受与python的新的非阻塞tls连接 [英] how to accept new non-blocking tls connection with python
本文介绍了如何接受与python的新的非阻塞tls连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在python中的非阻塞套接字上写一个tls服务器。
我的代码片段:
Hi,
I am trying to write a tls server over non blocking socket in python.
my code snippet:
newsocket, fromaddr = bindsocket.accept()
newsocket.setblocking(0)
connstream = ssl.wrap_socket(newsocket,
server_side=True,
certfile="cert.pem",
keyfile="key.pem",
ssl_version=ssl.PROTOCOL_TLSv1)
wrap_socket因想要读/写而失败。根据文档( python ssl )我需要在connstream上调用do_handshake(),但问题是connstream是没有返回所以不能调用do_handshake()就可以了。
接受tls连接的最佳和最快方法是什么?
wrap_socket fails with want read/write. as per documentation (python ssl) i need to call do_handshake() on connstream but the trouble is connstream is not returned so cant call do_handshake() on it.
What is the best and fastest way to accept tls connection?
推荐答案
看看< a href =http://www.gevent.org/gevent._ssl3.html> Gevent模块,它专为非阻塞而设计。
Take a look at Gevent module, it is designed for non blocking.
这篇关于如何接受与python的新的非阻塞tls连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文