int StreamPeerSSL::bio_read( BIO *b, char *buf, int len ) {
if ( buf == NULL || len <= 0 ) return 0;
StreamPeerSSL * sp = (StreamPeerSSL*)b->ptr;
if (sp->base.is_null())
return 0;
BIO_clear_retry_flags( b );
Error err;
int ret=0;
if (sp->block) {
err = sp->base->get_data((const uint8_t*)buf,len);
if (err==OK)
ret=len;
} else {
err = sp->base->get_partial_data((const uint8_t*)buf,len,ret);
if (err==OK && ret!=len) {
BIO_set_retry_write( b );
}
}
return ret;
}