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.

CC3220: making SlNetSock_recv return 0 when no data is availible

Part Number: CC3220


Hi all,

I would like to keep using the SlNet library but it's not async and receiving data make the task stuck.

There is a solution that can change SlNetSock_recv so it will return 0 (len=0) when there is no data?

Thanks.

  • Hi Netanel,

    Seems like the socket you set up is a blocking socket.

    Depending on your application needs, you could enable a receive timeout with blocking socket, OR you could use non-blocking sockets.

    In either case, if the there is no data to receive, SlNetSock_recv would return error code (negative value).


    Regards,
    Toby
  • took me a while to find it:

    struct SlNetSock_Timeval_t timeVal;
    timeVal.tv_sec = 1; // Seconds
    timeVal.tv_usec = 0; // Microseconds. 10000 microseconds resolution
    SlNetSock_setOpt(ssock, SLNETSOCK_LVL_SOCKET, SLNETSOCK_OPSOCK_RCV_TIMEO, (uint8_t *)&timeVal, sizeof(timeVal)); // Enable receive timeout


    found in slnetsock.h


    Thanks for navigate me to the word "timeout" never thought of it :)