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/CC3120MOD: Receive whole Messages with sl_Recv

Part Number: CC3120MOD

Tool/software: TI-RTOS

Hello,

I want to receive whole packages with sl_Recv, but in the documentation here: dev.ti.com/.../group___socket.html
It says flags are not supported.

I want to do something similar like this:

recv(socket_rcv, bufferRx, PACKETSIZE, MSG_WAITALL);

I don't know the exact packetsize so this is no option for me.

Currently i have no idea how to move around this problem.

Greetings,
Marvin

  • Hi Marvin,

    This API if for TCP communication and from this reason there is nothing like a "whole packet". You can read only data available in internal buffers. By len parameter you specify size of your buffer to avoid overflow of your buffer.

    Jan
  • Hi Jan,

    I misunderstood the "MSG_WAITALL" flag. And thought it returns after "a full package" but like you already mentioned there is nothing like this in TCP Communication.

    I solved the initial problem i had in another way.

    But to get something similar like the "MSG_WAITALL" flag I wrote this code:

    		while (len > 0)
    		{
    			recv_size = len;
    			
    			rc = sl_Recv(my_socket, buffer + recvLen, recv_size, 0);
    			len = len - rc;
    			if (rc < 0)
    			{
    				recvLen = -1;
    				break;
    			}
    			else if (rc == 0)
    			{
    				recvLen = 0;
    				break;
    			}
    			else if (rc > 0)
    			{
    				recvLen += rc;
    			}
    		}

    Thanks,

    Marvin

  • Hi Marvin,

    Yes, this is one of the possible ways, in case of that you want read exact number of bytes from socket.

    Jan