openssl的BIO方式如何设置ssl连接超时?

代码如下:但是感觉没啥作用。
BIO_set_nbio(bio,1);
DEBUG_INFO;
/* Create and setup the connection */
BIO_set_conn_ip(bio,argv[1]);
BIO_set_conn_port(bio,argv[2]);
int flag=0;
ret= BIO_do_connect(bio);
if(ret<=0&&!BIO_should_retry(bio))
{
printf("failed to establish connection\n");
return 0;
}
if(BIO_get_fd(bio,&sockfd)<0)
{
printf("failed to get fd\n");
return 0;
}
if(ret<=0)
{
FD_ZERO(&connectionfds);
FD_SET(sockfd, &connectionfds);
timeout.tv_usec = 0;
timeout.tv_sec = TIMEOUT;
if(select(sockfd+1,NULL,&connectionfds,NULL,&timeout)==0)
{
flag=0;
}

    }
    else
    {
            flag=1;
    }

    BIO_set_nbio(bio,0);

if(1==flag)
{
printf("Connect successfully !\n");
ShowCerts(ssl,argv[1],atoi(argv[2]));
}
else
{
printf("time out !\n");

    }

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐