You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "acassis (via GitHub)" <gi...@apache.org> on 2023/01/27 18:52:38 UTC

[GitHub] [nuttx] acassis commented on a diff in pull request #8297: tcp/udp_connect: If the remote addr is ANY, change it to LOOPBACK

acassis commented on code in PR #8297:
URL: https://github.com/apache/nuttx/pull/8297#discussion_r1089307963


##########
net/tcp/tcp_conn.c:
##########
@@ -1242,7 +1242,14 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr)
 
       /* The sockaddr address is 32-bits in network order. */
 
-      net_ipv4addr_copy(conn->u.ipv4.raddr, inaddr->sin_addr.s_addr);
+      if (inaddr->sin_addr.s_addr == INADDR_ANY)
+        {
+          net_ipv4addr_copy(conn->u.ipv4.raddr, HTONL(INADDR_LOOPBACK));
+        }
+      else
+        {
+          net_ipv4addr_copy(conn->u.ipv4.raddr, inaddr->sin_addr.s_addr);
+        }

Review Comment:
   So, 0.0.0.0 means 127.0.0.1? Is that the idea? Maybe should be a good idea include a comment.



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