This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] RTOS/PROCESSOR-SDK-AM335X:BSD 套接字错误

Guru**** 2925550 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/666135/rtos-processor-sdk-am335x-bsd-socket-errors

器件型号:PROCESSOR-SDK-AM335X
Thread 中讨论的其他器件:SYSBIOS

工具/软件:TI-RTOS

您好!

尝试使用 BSD 套接字时遇到问题。     随附一个小型测试程序 (test.c)、用于演示我看到的内容。     问题是 IP6N SELECT 的类型错误冲突。     

我已在项目中设置 NDK BSD 目录的包含路径。     项目的包含路径:

编译器输出:

和 test.c 程序:

 

/*
 * test.c
 *
 * 创建日期:2018年2月21日
 *     作者:MSTEINMEMZ_LA
 *


#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#include   // osif.h 需要此功能????   手柄、


#include         //包括 BSD 套接字

#include
#include "assert.h"


int bsd_test (void) {

   Int SocketHandle;

   int rslt;
   int rtn_addrlen;
   struct sockaddr_in addr;
   Int sockAddrSize;
   int msglen;
   struct sockaddr 发件人;
   unsigned char buf[1024];


   /*创建套接字--用于 UDP 消息传送*/
   SocketHandle = socket (AF_iNet、SOCK_DGRAM、0);

   if (-1 = SocketHandle)
   {
        /*无法创建套接字...报告问题,然后终止任务*/

       xdc_runtime_System_printf ("套接字创建失败\n");
       xdc_runtime_System_flush ();

   }
       /*接下来将套接字绑定到 IP 地址和端口*/

   sockAddrSize = sizeof (struct sockaddr_in);
   memset ((char *)&addr、0、sockAddrSize);
   addr.sin 系列=AF_iNet;
   Addr.Sin_port = htons(123);
   addr.sin addr.s_addr = htonl (INADDR_ANY);  //这应该是任何 IP 还是本地 IP????*

   rslt = bind (SocketHandle、(struct sockadr *)&addr、sockAddrSize);

   如果(-1 == rslt)
   {
       /*无法绑定端口...报告问题,然后终止任务*/
       //Fatal_error ("UDP ADDR 绑定错误");
       //taskDelete (taskIdSelf ());
       xdc_runtime_System_printf ("套接字绑定失败\n");
       xdc_runtime_System_flush ();

   }


   /*接下来、将停在套接字上等待对等 PRIM UDP */


   rtn_addrlen = sizeof (struct sockaddr_in);

   msglen = recvfrom (SocketHandle、buf、1024、0、 &from、 rtn_addrlen (&R);

   返回 msglen;

如果我删除 usertype.h include、 则缺少 typedef 的内容会在 osif.h 文件中生成错误。

我不确定我需要什么来解决冲突类型错误、还满足 osif.h 的必要 typedef

非常感谢您提供的任何帮助。     请注意、我确实在论坛中搜索并找到了有关冲突类型的另一个主题、 但似乎没有明确的答案、而该人只是通过黑客攻击来使其正常工作。   我希望有一个更清晰的答案。

谢谢、

标记

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    RTOS 团队已收到通知。 他们将在这里作出回应。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Mark、您好!

    您似乎已经按照 NDK API 参考指南中"3.4.1使用 BSD 套接字兼容层"一节中的步骤进行了操作。

    对于"IP6N"冲突、如果您注释以下内容、则应解决该问题:

    #include

    #include

    在 bsd_test.c 中

    并仅为 bsd_test.c 文件添加 include 路径"C:\ti\ndk_2_26_00_08\packages/ti\ndk\inc\bSD"。

    GCC v6.3.1的 sys/select.h 中似乎引入了"选择"冲突。  使用 bsd_test.c 中定义的'__inside_Cygwin_NET___''符号,可以禁用 GCC sys/select.h 中的 select()函数。 可能还有其他方法可以解决"选择"冲突。

    #if !defined (__inside_Cygwin_NET__)

    _Begin_DECLS

    int select __P ((int __n、fd_set *__readfds、fd_set *__writefds、

    fd_set *_ exceptfds、struct timeval *_超时);

    #if __posix_visible >=200112

    int pselect __P ((int __n、fd_set *__readfds、fd_set *__writefds、

     fd_set *_exceptfds、const struct timespec *__timeout、

     const sigset_t *_设置);

    #endif

    _END_DECLS

    #endif /*!__inside_Cygwin_NET___*/

    此致、

    Garrett

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢 Garrett  、正如您所建议的那样、解决了问题。

    标记