Skip to content

Commit

Permalink
mqtt_pal.h: Document the canonical way to report errors
Browse files Browse the repository at this point in the history
The protocol suggested in LiamBindle#110
  • Loading branch information
yamt committed Feb 4, 2022
1 parent be12c34 commit 8089a36
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/mqtt_pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ extern "C" {
* @param[in] flags Flags which are passed to the underlying socket.
*
* @returns The number of bytes sent if successful, an \ref MQTTErrors otherwise.
*
* Note about the error handling:
* - On an error, if some bytes have been processed already,
* this function should return the number of bytes successfully
* processed. (partial success)
* - Otherwise, if the error is an equivalent of EAGAIN, return 0.
* - Otherwise, return MQTT_ERROR_SOCKET_ERROR.
*/
ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags);

Expand All @@ -173,6 +180,13 @@ ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len,
* @param[in] flags Flags which are passed to the underlying socket.
*
* @returns The number of bytes received if successful, an \ref MQTTErrors otherwise.
*
* Note about the error handling:
* - On an error, if some bytes have been processed already,
* this function should return the number of bytes successfully
* processed. (partial success)
* - Otherwise, if the error is an equivalent of EAGAIN, return 0.
* - Otherwise, return MQTT_ERROR_SOCKET_ERROR.
*/
ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags);

Expand Down

0 comments on commit 8089a36

Please sign in to comment.