代码如下:但是感觉没啥作用。
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");
}