zhhyu7 commented on code in PR #21418:
URL: https://github.com/apache/nuttx/pull/21418#discussion_r4463566930


##########
net/local/local_sockif.c:
##########
@@ -822,9 +832,36 @@ static int local_connect(FAR struct socket *psock,
 #ifdef CONFIG_NET_LOCAL_DGRAM
       case SOCK_DGRAM:
         {
-          /* Perform the datagram connection logic */
+          FAR struct local_conn_s *conn = psock->s_conn;
+          FAR const struct sockaddr_un *unaddr =
+              (FAR const struct sockaddr_un *)addr;
+
+          if (addr->sa_family == AF_UNSPEC)
+            {
+              memset(&conn->lc_daddr, 0, sizeof(conn->lc_daddr));
+              if (conn->lc_state == LOCAL_STATE_CONNECTED)
+                {
+                  conn->lc_state = conn->lc_type == LOCAL_TYPE_UNNAMED
+                                   ? LOCAL_STATE_UNBOUND
+                                   : LOCAL_STATE_BOUND;
+                }
+
+              return OK;
+            }
+
+          /* Record the default peer.  Copy only what the caller supplied
+           * so that a short addrlen does not read past its buffer.
+           */
 
-          return -ENOSYS;
+          if (addrlen > sizeof(conn->lc_daddr))
+            {
+              addrlen = sizeof(conn->lc_daddr);
+            }
+
+          memset(&conn->lc_daddr, 0, sizeof(conn->lc_daddr));
+          memcpy(&conn->lc_daddr, unaddr, addrlen);
+          conn->lc_state = LOCAL_STATE_CONNECTED;

Review Comment:
   Done.



##########
net/local/local_bind.c:
##########
@@ -100,6 +100,27 @@ int psock_local_bind(FAR struct socket *psock,
 
   strlcpy(conn->lc_path, &unaddr->sun_path[index], sizeof(conn->lc_path));
 
+#ifdef CONFIG_NET_LOCAL_DGRAM
+  if (psock->s_type == SOCK_DGRAM)
+    {
+      int ret;
+
+      ret = local_create_halfduplex(conn, conn->lc_path, conn->lc_rcvsize);
+      if (ret < 0)
+        {
+          return ret;
+        }
+
+      ret = local_open_receiver(conn,

Review Comment:
   Done



-- 
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]

Reply via email to