Describe the bug
SOCKETS_Send is wrongly used (or wrongly documented); returning less than the expected number of bytes is treated as error in some places.
/**
* @brief Transmit data to the remote socket.
*
* The socket must have already been created using a call to SOCKETS_Socket() and
* connected to a remote socket using SOCKETS_Connect().
*
* See the [Berkeley Sockets API]
* (https://en.wikipedia.org/wiki/Berkeley_sockets#Socket_API_functions)
* in wikipedia
*
* @param[in] xSocket The handle of the sending socket.
* @param[in] pvBuffer The buffer containing the data to be sent.
* @param[in] xDataLength The length of the data to be sent.
* @param[in] ulFlags Not currently used. Should be set to 0.
*
* @return
* * On success, the number of bytes actually sent is returned.
* * If an error occurred, a negative value is returned. @ref SocketsErrors
*/
/* @[declare_secure_sockets_send] */
int32_t SOCKETS_Send( Socket_t xSocket,
const void * pvBuffer,
size_t xDataLength,
uint32_t ulFlags );
Describe the bug SOCKETS_Send is wrongly used (or wrongly documented); returning less than the expected number of bytes is treated as error in some places.
https://github.com/aws/amazon-freertos/blob/master/libraries/abstractions/secure_sockets/include/iot_secure_sockets.h documents
"On success, the number of bytes actually sent is returned." in my understanding also allows only partial sends, so returning a number of bytes > 0 but < xDataLength. Coming from an old version ( https://github.com/aws/amazon-freertos/blob/master/CHANGELOG.md#v148-05212019 ), this is also how it worked fine there. If you returned less bytes, SOCKETS_Send was called with the remaining bytes. This pattern is also still present in source files like https://github.com/aws/amazon-freertos/blob/master/libraries/freertos_plus/aws/greengrass/src/aws_helper_secure_connect.c :
used by (and treated as error if not all bytes ahve been transmitted) in https://github.com/aws/amazon-freertos/blob/master/libraries/c_sdk/standard/mqtt/src/iot_mqtt_operation.c
Expected behavior
SOCKETS_Send should be repeatedly called until all data is sent in all places using it, or SOCKETS_Send interface documentation be changed.