acassis commented on code in PR #14554:
URL: https://github.com/apache/nuttx/pull/14554#discussion_r1823233898
##########
libs/libc/netdb/lib_dnsquery.c:
##########
@@ -110,6 +110,133 @@ struct dns_query_data_s
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: stream_send
+ ****************************************************************************/
+
+static ssize_t stream_send(int fd, FAR const void *buf, size_t len)
+{
+ ssize_t total = 0;
+
+ while (len > 0)
+ {
+ ssize_t ret = send(fd, buf, len, 0);
+ if (ret == -1)
+ {
+ if (total == 0)
+ {
+ total = ret;
+ }
+ break;
+ }
+
+ buf = (FAR const uint8_t *)buf + len;
+ len -= ret;
+ total += ret;
+ }
+
+ return total;
+}
+
+/****************************************************************************
+ * Name: stream_recv
+ ****************************************************************************/
+
+static ssize_t stream_recv(int fd, FAR void *buf, size_t len)
+{
+ ssize_t total = 0;
+
+ while (len > 0)
+ {
+ ssize_t ret = recv(fd, buf, len, 0);
+ if (ret == 0)
+ {
+ /* the peer closed the connection */
+
+ set_errno(EMSGSIZE);
+ ret = -1;
+ }
+
+ if (ret == -1)
+ {
+ if (total == 0)
+ {
+ total = ret;
+ }
+ break;
+ }
+
+ buf = (FAR uint8_t *)buf + len;
+ len -= ret;
+ total += ret;
+ }
+
+ return total;
+}
+
+/****************************************************************************
+ * Name: stream_send_record
Review Comment:
ditto
##########
libs/libc/netdb/lib_dnsquery.c:
##########
@@ -110,6 +110,133 @@ struct dns_query_data_s
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: stream_send
+ ****************************************************************************/
+
+static ssize_t stream_send(int fd, FAR const void *buf, size_t len)
+{
+ ssize_t total = 0;
+
+ while (len > 0)
+ {
+ ssize_t ret = send(fd, buf, len, 0);
+ if (ret == -1)
+ {
+ if (total == 0)
+ {
+ total = ret;
+ }
+ break;
+ }
+
+ buf = (FAR const uint8_t *)buf + len;
+ len -= ret;
+ total += ret;
+ }
+
+ return total;
+}
+
+/****************************************************************************
+ * Name: stream_recv
+ ****************************************************************************/
+
+static ssize_t stream_recv(int fd, FAR void *buf, size_t len)
+{
+ ssize_t total = 0;
+
+ while (len > 0)
+ {
+ ssize_t ret = recv(fd, buf, len, 0);
+ if (ret == 0)
+ {
+ /* the peer closed the connection */
+
+ set_errno(EMSGSIZE);
+ ret = -1;
+ }
+
+ if (ret == -1)
+ {
+ if (total == 0)
+ {
+ total = ret;
+ }
+ break;
+ }
+
+ buf = (FAR uint8_t *)buf + len;
+ len -= ret;
+ total += ret;
+ }
+
+ return total;
+}
+
+/****************************************************************************
+ * Name: stream_send_record
+ ****************************************************************************/
+
+static ssize_t stream_send_record(int fd, FAR const void *buf, size_t len)
+{
+ ssize_t ret;
+ uint8_t reclen[2];
+
+ /* RFC 1035
+ * 4.2.2. TCP usage
+ *
+ * > The message is prefixed with a two byte length field which
+ * > gives the message length, excluding the two byte length field.
+ */
+
+ reclen[0] = (uint8_t)(len >> 8);
+ reclen[1] = (uint8_t)len;
+ ret = stream_send(fd, reclen, sizeof(reclen));
+ if (ret < sizeof(reclen))
+ {
+ return -1;
+ }
+
+ return stream_send(fd, buf, len);
+}
+
+/****************************************************************************
+ * Name: stream_recv_record
Review Comment:
ditto
##########
libs/libc/netdb/lib_dnsquery.c:
##########
@@ -110,6 +110,133 @@ struct dns_query_data_s
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: stream_send
+ ****************************************************************************/
+
+static ssize_t stream_send(int fd, FAR const void *buf, size_t len)
+{
+ ssize_t total = 0;
+
+ while (len > 0)
+ {
+ ssize_t ret = send(fd, buf, len, 0);
+ if (ret == -1)
+ {
+ if (total == 0)
+ {
+ total = ret;
+ }
+ break;
+ }
+
+ buf = (FAR const uint8_t *)buf + len;
+ len -= ret;
+ total += ret;
+ }
+
+ return total;
+}
+
+/****************************************************************************
+ * Name: stream_recv
Review Comment:
ditto
##########
libs/libc/netdb/lib_dnsquery.c:
##########
@@ -110,6 +110,133 @@ struct dns_query_data_s
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: stream_send
Review Comment:
Please add Description as in the existing functions here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]