BIO_read(3) OpenSSL BIO_read(3) NNAAMMEE BIO_read, BIO_write, BIO_gets, BIO_puts - BIO I/O functions SSYYNNOOPPSSIISS #include int BIO_read(BIO *b, void *buf, int len); int BIO_gets(BIO *b, char *buf, int size); int BIO_write(BIO *b, const void *buf, int len); int BIO_puts(BIO *b, const char *buf); DDEESSCCRRIIPPTTIIOONN _B_I_O___r_e_a_d_(_) attempts to read lleenn bytes from BIO bb and places the data in bbuuff. _B_I_O___g_e_t_s_(_) performs the BIOs "gets" operation and places the data in bbuuff. Usually this operation will attempt to read a line of data from the BIO of maximum length lleenn. There are exceptions to this however, for example _B_I_O___g_e_t_s_(_) on a digest BIO will calculate and return the digest and other BIOs may not support _B_I_O___g_e_t_s_(_) at all. _B_I_O___w_r_i_t_e_(_) attempts to write lleenn bytes from bbuuff to BIO bb. _B_I_O___p_u_t_s_(_) attempts to write a null terminated string bbuuff to BIO bb. RREETTUURRNN VVAALLUUEESS All these functions return either the amount of data successfully read or written (if the return value is positive) or that no data was suc- cessfully read or written if the result is 0 or -1. If the return value is -2 then the operation is not implemented in the specific BIO type. NNOOTTEESS A 0 or -1 return is not necessarily an indication of an error. In par- ticular when the source/sink is non-blocking or of a certain type it may merely be an indication that no data is currently available and that the application should retry the operation later. One technique sometimes used with blocking sockets is to use a system call (such as _s_e_l_e_c_t_(_), _p_o_l_l_(_) or equivalent) to determine when data is available and then call _r_e_a_d_(_) to read the data. The equivalent with BIOs (that is call _s_e_l_e_c_t_(_) on the underlying I/O structure and then call _B_I_O___r_e_a_d_(_) to read the data) should nnoott be used because a single call to _B_I_O___r_e_a_d_(_) can cause several reads (and writes in the case of SSL BIOs) on the underlying I/O structure and may block as a result. Instead _s_e_l_e_c_t_(_) (or equivalent) should be combined with non blocking I/O so successive reads will request a retry instead of blocking. See _B_I_O___s_h_o_u_l_d___r_e_t_r_y(3) for details of how to determine the cause of a retry and other I/O issues. If the _B_I_O___g_e_t_s_(_) function is not supported by a BIO then it possible to work around this by adding a buffering BIO _B_I_O___f___b_u_f_f_e_r(3) to the chain. SSEEEE AALLSSOO _B_I_O___s_h_o_u_l_d___r_e_t_r_y(3) TBA 1.0.1u 2016-09-22 BIO_read(3)