有没有办法把stdin/stdout个fd转成一个fd?

Is there a way to convert stdin/stdout fds into one fd?

我想从 stdin 处理 SSL,并从 stdout 发送 SSL,但 OpenSSL 在 set fd 调用中只接受一个文件描述符:

SSL_set_fd(ssl, sock);

有没有办法将 stdin 和 stdout 文件描述符合并为一个?

我意识到我可以创建一个只从 stdin/out 读取并写入文件描述符的进程,但我试图想出一种方法来避免额外的处理层。

您似乎想使用 SSL_set_rfd() 和 SSL_set_wfd()。来自 the manual:

SSL_set_rfd() and SSL_set_wfd() perform the respective action, but only for the read channel or the write channel, which can be set independently.