请教下Openssl怎么使用异步

zhousitiaoda zhousitiaoda 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
https请求,使用的openssl,网上的例子基本都是同步的,想使用异步,查了下官方资料,貌似本身不提供异步,其异步更多的依赖于socket本身。比如SSL_accept(如果我没理解错的话)

NOTES

The behaviour of SSL_accept() depends on the underlying BIO.

If the underlying BIO is blocking, SSL_accept() will only return once the handshake has been finished or an error occurred.

If the underlying BIO is non-blocking, SSL_accept() will also return when the underlying BIO could not satisfy the needs of SSL_accept() to continue the handshake, indicating the problem by the return value -1. In this case a call to SSL_get_error() with the return value of SSL_accept() will yield SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE. The calling process then must repeat the call after taking appropriate action to satisfy the needs of SSL_accept(). The action depends on the underlying BIO. When using a non-blocking socket, nothing is to be done, but select() can be used to check for the required condition. When using a buffering BIO, like a BIO pair, data must be written into or retrieved out of the BIO before being able to continue.

如果是这样的话,有没有什么好的框架,自己裸写感觉成本有点高。试了下WSAEventSelect貌似不行,只要有连接进来,只要对新连接返回的socket调用WSAEventSelect就会导致SSL的accept失败。
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
zhousitiaoda
网络编程 18,356 成员 64,161 内容