riot_sys

Function sock_tcp_read

Source
pub unsafe extern "C" fn sock_tcp_read(
    sock: *mut sock_tcp_t,
    data: *mut c_void,
    max_len: size_t,
    timeout: u32,
) -> ssize_t
Expand description

@brief Reads data from an established TCP stream

@pre (sock != NULL) && (data != NULL) && (max_len > 0)

@param[in] sock A TCP sock object. @param[out] data Pointer where the read data should be stored. @param[in] max_len Maximum space available at @p data. If read data exceeds @p max_len the data is truncated and the remaining data can be retrieved later on. @param[in] timeout Timeout for receive in microseconds. If 0 and no data is available, the function returns immediately. May be @ref SOCK_NO_TIMEOUT for no timeout (wait until data is available).

@note Function may block.

@return The number of bytes read on success. @return 0, if no read data is available or the connection was orderly closed by the remote host. @return -EAGAIN, if @p timeout is 0 and no data is available. @return -ECONNABORTED, if the connection is aborted while waiting for the next data. @return -ECONNRESET, if the connection was forcibly closed by remote end point of @p sock. @return -ENOTCONN, when @p sock is not connected to a remote end point. @return -ETIMEDOUT, if @p timeout expired.