Function s2n_tls_sys::s2n_recv

source ·
pub unsafe extern "C" fn s2n_recv(
    conn: *mut s2n_connection,
    buf: *mut c_void,
    size: isize,
    blocked: *mut Type
) -> isize
Expand description

Decrypts and reads *size to buf data from the associated connection.

@note Unlike OpenSSL, repeated calls to s2n_recv should not duplicate the original parameters, but should update buf and size per the indication of size read. For example;

s2n_blocked_status blocked;
int bytes_read = 0;
char data[10];
do {
    int r = s2n_recv(conn, data + bytes_read, 10 - bytes_read, &blocked);
    if (r < 0) {
        break;
    }
    bytes_read += r;
} while (blocked != S2N_NOT_BLOCKED);

@param conn A pointer to the s2n_connection object @param buf A pointer to a buffer that s2n will place read data into. @param size Size of buf @param blocked A pointer which will be set to the blocked status, as in s2n_negotiate() @returns number of bytes read. 0 if the connection was shutdown by peer.