You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/09/20 14:02:57 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7124: net: Implement SO_RCVBUF and SO_SNDBUF for getsockopt

xiaoxiang781216 commented on code in PR #7124:
URL: https://github.com/apache/incubator-nuttx/pull/7124#discussion_r975408249


##########
net/socket/getsockopt.c:
##########
@@ -260,14 +261,90 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
         break;
 #endif
 
+#if CONFIG_NET_RECV_BUFSIZE > 0
+      case SO_RCVBUF:     /* Reports receive buffer size */
+        {
+          if (*value_len != sizeof(int))
+            {
+              return -EINVAL;
+            }
+
+#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
+          if (psock->s_type == SOCK_STREAM)
+            {
+              FAR struct tcp_conn_s *tcp;
+
+              tcp = (FAR struct tcp_conn_s *)conn;
+
+              *(FAR int *)value = tcp->rcv_bufs;
+            }
+          else
+#endif
+#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
+          if (psock->s_type == SOCK_DGRAM)
+            {
+              FAR struct udp_conn_s *udp;
+
+              udp = (FAR struct udp_conn_s *)conn;
+
+              *(FAR int *)value = udp->rcvbufs;
+            }
+          else
+#endif
+            {
+              return -ENOPROTOOPT;
+            }

Review Comment:
   The code is copied from:
   https://github.com/apache/incubator-nuttx/blob/master/net/socket/setsockopt.c#L279-L401
   so it's better to keep consistent between them.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org