mbedtls_net_recv_timeout() function
Read at most 'len' characters, blocking for at most 'timeout' seconds. If no error occurs, the actual amount read is returned.
Syntax
int mbedtls_net_recv_timeout(void *ctx,
unsigned char *buf,
size_t len,
uint32_t timeout);
Arguments
buf
The buffer to write to
len
Maximum length of the buffer
timeout
Maximum number of milliseconds to wait for data 0 means no timeout (wait forever)
Return value
The number of bytes received if successful. MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out. MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal. Another negative error code (MBEDTLS_ERR_NET_xxx) for other failures.
Notes
The current implementation of this function uses select() and returns an error if the file descriptor is \c FD_SETSIZE or greater. This function will block (until data becomes available or timeout is reached) even if the socket is set to non-blocking. Handling timeouts with non-blocking reads requires a different strategy.
mbedtls_net_recv_timeout() calls 2 functions:
![]()
mbedtls_net_recv_timeout()
mbedtls_net_recv_timeout() reads 1 variable:
![]()
mbedtls_net_recv_timeout()