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.

NDK: blocking recv()



Hello,

i am trying to send a chunk of data via TCP/IP from a linux client to my C6474 evaluation board using NDK 2 and SYS/BIOS 6. I use connection-oriented sockets. The server sets up a socket and listens, the client connects. Everything fine up to this point.

The client code looks like this

#define BIG_CHUNK_SIZE 6400
#define SMALL_CHUNK_SIZE 640


    char *buffer = (char*) malloc(BUF_SIZE*sizeof(char)); // BUF_SIZE = 8192
    memset(buffer, 0, BUF_SIZE*sizeof(char));

    int numByteSent = 0;
    int result;
    fprintf(stdout, "Trying to send %d byte\n", BIG_CHUNK_SIZE); fflush(stdout);
    while (numByteSent < BIG_CHUNK_SIZE) {
        result = send(socketDesc, (void*) &buffer[numByteSent], SMALL_CHUNK_SIZE, 0);

        if (result < 0) {
            perror("send()");
        } else {
            fprintf(stdout, "Sent %d byte\n", result); fflush(stdout);
            numByteSent += result;
        }
    }
    fprintf(stdout, "Done\n"); fflush(stdout);

The server side like this

#define BIG_CHUNK_SIZE 6400
#define SMALL_CHUNK_SIZE 640

    printf("Trying to receive %d Byte\n", BIG_CHUNK_SIZE);
    while (numByteRcvd < BIG_CHUNK_SIZE) {
        result = recv(socketDescPeer, (void*) &buffer[numByteRcvd], SMALL_CHUNK_SIZE, 0);
        if (result < 0) {
            printf("recv(): Error %d\n", fdError());
        } else {
            printf("Received %d byte\n", result);
            numByteRcvd += result;
        }
    }
    printf("done\n");

The client sends 10 messages of 640 bytes each as expected. The server successfully receives the first message, also 640 Bytes, then calls recv() again which in turn blocks. I tried smaller amounts of data and chunk sizes. Interestingly, for 64 Byte chunks, the server successfully receives the first few (10 or so) chunks. For small amounts of data the transmission works however. Thanks for any help.

Best regards

  • Can you please provide your full 4-digit version numbers?   For example, SYS/BIOS 6.37.0x.yz.   Where x, y, and z are numbers.

    Not sure if it matters, but the standard printf() code sets a hidden breakpoint in CCS.  So, your target is quietly halting/running to manage the printf() code.   You might try removing those calls or replacing them with "System_printf()" to see if that cures the problem.

    Thanks,
    -Karl-

  • Hello Karl,

    Thanks for your answer. The complete version numbers are SYS/BIOS 6.30.02.42 and NDK 2.20.2.22.

    I tried removing the printf()s, but that didnt change anything. Also, i stepped over the calls to recv() in the debugger explicitly to confirm that its the call to recv() which is blocking.

    Any other ideas?

    Best regards

  • Did you start with the MCSDK example or your own?

    Regards,

    Travis

     

  • Hello tscheck,

    I started my own project. Interestingly, i can send data from a windows machine without problems. The problem occurs only when sending data from a linux client.

  • Max,


    Are you using our NIMU driver though?  We've seen failures like this before where a Linux PC will send out big packets, 1514B, while a Windows PC will not.  When the incoming packets are 1514 bytes (14 MAC+ 20 IP + 20 TCP + 1460 data), it has 1500 bytes for IP layer and is classified as oversized packets. A one line change to the nimu_eth.h file fixed the issue by changing the NIMU_EMAC_PKT_SIZE = 1514 to NIMU_EMAC_PKT_SIZE = 1518.  Can you try changing this and rebuilding?  The file is located at:

    C:\Program Files (x86)\Texas Instruments\mcsdk_1_00_00_08\packages\ti\platform\nimu\src\inc

    Regards,

    Travis

  • Hi TI Support Team,

    this post is more than two years old, but the issue is also persistant in the latest PDK of C6657 (processor_sdk_rtos_c665x_3_01_00_06). Please, would you fill a bug report to track the issue?

    Thanks and kind regards
    Sven
  • Hi Sven,
    We generally discourage posting a new question to an old closed thread because the person who answered before may no longer be available, and also it will allow whomever is currently assigned to monitor the forum to respond to you more quickly. For these reasons, I suggest you start a new thread with your question and reference this thread.

    Thank you