Allows to read the provided amount of bytes from the provided connection, leaving the content read on the buffer provided. Optionally, the function allows blocking the caller until the amount of bytes requested are satisfied. Also, the function allows to timeout the operation after provided amount of time.
Note that the function doesn't clear the buffer received. Only memory (bytes) notified by the value returned by this function should be accessed by the caller. In the same direction you can't use the buffer as a nul-terminated string because the function doesn't add the final \0 to the content read. More calls to nopoll_conn_read might be needed Because nopoll_conn_read calls to nopoll_conn_get_msg to get content to satisfy buffer read requested, it might happen that the actual amount of bytes requested by this function (nopoll_conn_read) is smaller than the number of bytes that can be satisfied (because nopoll_conn_get_msg reported a noPollMsg with bigger content). In such case, these bytes will be reported on next call to nopoll_conn_read. However, it might also happen that the socket is being watched (by select(), poll(), epoll(), similar mechanism) and because all bytes have been read and are retained in a noPollMsg inside the provided noPollConn) this might cause a block until a forced nopoll_conn_read happens again (because the socket does not report any content to be read and nopoll_conn_read is not called). In such scenarios, if you want to avoid such lockings, please use nopoll_conn_read_pending to do more calls to nopoll_conn_read References nopoll_conn_get_msg(), nopoll_conn_is_ok(), NOPOLL_EWOULDBLOCK, NOPOLL_LEVEL_CRITICAL, NOPOLL_LEVEL_DEBUG, nopoll_msg_get_payload(), nopoll_msg_get_payload_size(), nopoll_msg_ref(), nopoll_msg_unref(), nopoll_sleep(), nopoll_timeval_substract(), and nopoll_true. |