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.

关于6455 ndk例程helloworld

请问有没有人遇到过这种情况,板子是dsk6455开发板,直接import的example的helloworld(include nimu code),使用DHCPC时获取不到IP地址,就修改了localIpAddress,配置了静态地址,并在NetworkOpen中TSK_create( dtask_udp_sendhello, &tskAttrs);dtask_udp_sendhello用来发送UDP数据包,但sendto失败,返回-1,ping 也失败。请问有没有人知道可能的原因,已经查好几天了,谢谢

[C64XP_0]
TCP/IP Stack 'Hello World!' Application

Using MAC Address: 00-01-22-33-44-55
EMAC should be up and running
EMAC has been started successfully
Registeration of the EMAC Successful
Link Status: 100Mb/s Full Duplex on PHY 1
Network Added: If-1:192.168.3.121

sendto failed, return num = -1

  • 请问发送的包长是多少?
  • 21个字节,pc与dsk6455直连或者通过交换机相连,都ping不通,发送UDP代码如下

    int dtask_udp_sendhello()
    {
    SOCKET s;
    struct sockaddr_in sAddr;
    struct sockaddr_in dAddr;
    char pBuf[] = "send data to test udp";
    int opVal = 0;
    int sendBytes = 0;

    memset(&sAddr, 0, sizeof(struct sockaddr_in));
    memset(&dAddr, 0, sizeof(struct sockaddr_in));

    s = socket(AF_INET, SOCK_DGRAM, 0);
    if(s < 0){
    printf("socket failed\n");
    return -1;
    }

    opVal = 1;
    setsockopt(s, SOL_SOCKET, SO_BROADCAST, &opVal, sizeof(int) );

    dAddr.sin_family = AF_INET;
    dAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);//INADDR_BROADCAST
    dAddr.sin_port = htons(12345);

    while(1){

    TSK_sleep(100);
    if((sendBytes = sendto(s, pBuf, strlen(pBuf), 0, (struct sockaddr *)&dAddr, sizeof(dAddr))) < 0){

    printf("sendto failed, return num = %d\n", sendBytes);
    //return -1;
    }
    }

    }