如何从BIO中检索fd以与select()一起使用?

时间:2016-10-06 07:31:54

标签: c++ openssl

我正在尝试通过将BIO设置为非阻塞,然后将读取(SSL_get_rbio)和写入(SSL_get_wbio)传递给select()语句来实现非阻塞SSL套接字

但是,我不确定如何传递这些,显然select语句只采用fd_set类型?

代码:

BIO *sslbio;
sslbio=BIO_new_socket(sock,BIO_NOCLOSE);
long block_status=1;
long nonb=BIO_set_nbio(sslbio,block_status);
BIO *r = SSL_get_rbio(ssl); 
BIO *w = SSL_get_wbio(ssl);
SSL_set_bio(ssl,r,w);

struct timeval tv, tvRestore;
tv.tv_sec=10;
tv.tv_usec=0;
tvRestore=tv;

if(SSL_accept(ssl) <= 0)
{
   std::cout<<"SSL_accept ERROR"<<std::endl;
}
else
{
   int select_int=select(client + 1,r,w,NULL,&tvRestore);
}

错误是:

"cannot convert ‘BIO* {aka bio_st*}’ to ‘fd_set*’ for argument ‘2’
  to ‘int select(int, fd_set*, fd_set*, fd_set*, timeval*)"

关于如何连接它们的任何想法?

0 个答案:

没有答案