Hi,
I'm writing an application which uses the BIO stuff, because
i need non-blocking support. I knew there are serveral comments
on that topic, but i have problems to get a fd out of the bio
structure.(i need it for select()) The macro BIO_get_fd returns 0,
even if the TCP/IP connection is established and BIO_do_handshake()
returns >0.
Ok, this is what i get without pushing the SSL to the BIO stuff
with BIO_push(ssl_bio, con_bio). If i pushed the ssl to bio,
BIO_do_handshake() returned <0 and BIO_should_retry() returned
0, which is a system error state.
Ok, what am i doing wrong. I'm using SSLeay-0.9.0 on AIX.
This is my code:
con_bio=BIO_new_connect(host);
SSLeay_add_ssl_algorithms();
ssl_ctx=SSL_CTX_new(SSLv23_client_method());
ssl_bio=BIO_new_ssl_connect(ssl_ctx);
bio=BIO_push(ssl_bio,con_bio);
i=BIO_do_handshake(con_bio);
if (i > 0)
{
printf("Connection established..\n");
p_ctrl->port_id=BIO_get_fd(bio,&p_ctrl->port_id);
printf("FD is... fd: %d\n",p_ctrl->port_id); /* fd = 0 ???*/
return(0); }
else if (i == 0)
{
printf("Connection failed..\n");
return(-1);
}
else if (i < 0)
{
if (BIO_should_retry(bio))
{ /* Was a non-blocking IO condition */
if (BIO_should_read(bio))
{ /* set select(2) flags accordingly */
}
else if (BIO_should_write(bio))
{ /* set select(2) flags accordingly */
}
else if (BIO_should_io_special(bio))
{
j=BIO_get_retry_reason(bio);
if (j == BIO_RR_CONNECT)
{
/* non-blocking connect, this
* is currently the only 'special'
* retry reason */
BIO_get_fd(bio,&p_ctrl->port_id);
printf("Waiting for next event... fd: %d\n",
p_ctrl->port_id);
return(EWOULDBLOCK);
}
}
}
else
{
printf("System error\n");
return(-1);
}
}
[EMAIL PROTECTED] | http://www.ikossvan.de
Softwareentwickler, ETA | IKOSS VAN GmbH
Tel.:+49 (2408) 148 301 | Geschaeftsbereich Netzwerke
Fax :+49 (2408) 148 204 | Pascalstr.19, 52076 Aachen
+-------------------------------------------------------------------------+
| Administrative requests should be sent to [EMAIL PROTECTED] |
| List service provided by Open Software Associates, http://www.osa.com/ |
+-------------------------------------------------------------------------+